I am trying to delete rows in an excel workbook that is currently being written to via my Access VBA (it is open using the following code).
Code:
strPath = "C:\test\test.xlsb"
Set ApXL = CreateObject("Excel.Application")
'Debug.Print strPath
Set xlWBk = ApXL.Workbooks.Open(strPath)
ApXL.Visible = False
I have the following code which currently runs in the workbook itself but I would like help converting it to run in the Access VBA code while I write all the data to it. Does anyone know now I can convert the following code to run in access?
Thank you in advance.
Code:
Dim iRowCountA As Integer, iRowCountB As Integer
iRowCountA = Range(Sheets("sheet1").Range("A2"), Sheets("sheet1").Range("A2").End(xlDown)).Rows.Count
iRowCountB = Range(Sheets("sheet2").Range("B10"), Sheets("sheet2").Range("B10").End(xlDown)).Rows.Count
Sheets("sheet2").Range("A" & iRowCountA + 10 & ":A" & iRowCountB + 10 - 1).EntireRow.Delete