Bruno
Bruno

Reputation: 6449

MS Access VBA How to delete a row in Excel

I have used the below code to open an 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

Upvotes: 1

Views: 17770

Answers (1)

Tim Williams
Tim Williams

Reputation: 166126

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

Upvotes: 9

Related Questions