开发者

MS Access VBA How to delete a row in Excel

开发者 https://www.devze.com 2023-03-28 10:47 出处:网络
I have used the below code to open an开发者_Go百科 Excel file in MS Access 2003. I would like to delete row 2 or A2:K2.

I have used the below code to open an开发者_Go百科 Excel file in MS Access 2003. I would like to delete row 2 or A2:K2.

            Dim xlApp As Excel.Application
            Set xlApp = CreateObject("Excel.Application")

            xlApp.Visible = True

            xlApp.Workbooks.Open "QuotebyItem.xls", True, False


Dim wb as Excel.Workbook
Dim xlApp As Excel.Application             

Set xlApp = CreateObject("Excel.Application")              
xlApp.Visible = True 

Set wb = xlApp.Workbooks.Open("QuotebyItem.xls", True, False)
wb.Sheets(1).Rows(2).Delete

...assuming your file has only one sheet: if there might be multiple and you need to address only one of them:

wb.Sheets("Sheet2").Rows(2).Delete
0

精彩评论

暂无评论...
验证码 换一张
取 消