Have an excel sheet that I want Access to open, delete the first 2 rows and then sort (remove all rows where column C does not equal "A0C6")
I can get the sorting code to work in excel, but not access.
I believe the bolded row is where I am getting the error.
Would appreciate any help!
Thanks a bunch!!
Function CleanupFile()
Dim oExcel As Object
Dim oBook As Object
Dim oRange As Object
Set oExcel = CreateObject("Excel.Application")
oExcel.Visible = True
Set oBook = oExcel.Workbooks.Open("H:\AER\IMPORTS\Inactive_Well_Licence_List.xlsx")
oBook.Sheets(1).Rows(1).Delete
oBook.Sheets(1).Rows(1).Delete
AutoFilterMode = False
With oRange("C2", oRange("C" & Rows.Count).End(xlUp))
.AutoFilter 1, "<>A0C6"
On Error Resume Next
.Offset(1).SpecialCells(12).EntireRow.Delete
End With
AutoFilterMode = False
oBook.Save
oBook.Close
oExcel.Quit
End Function
I can get the sorting code to work in excel, but not access.
I believe the bolded row is where I am getting the error.
Would appreciate any help!
Thanks a bunch!!
Code:
Dim oExcel As Object
Dim oBook As Object
Dim oRange As Object
Set oExcel = CreateObject("Excel.Application")
oExcel.Visible = True
Set oBook = oExcel.Workbooks.Open("H:\AER\IMPORTS\Inactive_Well_Licence_List.xlsx")
oBook.Sheets(1).Rows(1).Delete
oBook.Sheets(1).Rows(1).Delete
AutoFilterMode = False
With oRange("C2", oRange("C" & Rows.Count).End(xlUp))
.AutoFilter 1, "<>A0C6"
On Error Resume Next
.Offset(1).SpecialCells(12).EntireRow.Delete
End With
AutoFilterMode = False
oBook.Save
oBook.Close
oExcel.Quit
End Function
Code: