开发者

MS Access VBA How to delete a row in Excel

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜