I download an excel spreadsheet from an outside source, and it comes in with a space before the data in column A. I need to remove this space before I import into my database.
I used this code in another function, and it worked perfectly. For some reason, I am getting an "Invalid Use of Null" error this time?
[/CODE]
I used this code in another function, and it worked perfectly. For some reason, I am getting an "Invalid Use of Null" error this time?
Code:
Function RemoveSpaceBeforeWellLicense()
Dim oExcel As Object
Dim oBook As Object
Set oExcel = CreateObject("Excel.Application")
oExcel.Visible = True
Set oBook = oExcel.Workbooks.Open("S:\Renée\Database downloads\AER\AER Suspended Well List.xls")
AutoFilterMode = False
With oBook.Sheets(1).Range("A2", oBook.Sheets(1).Range("A" & oBook.Sheets(1).Rows.Count).End(xlUp))
[COLOR=red].Value = VBA.Replace(.Text, " ", "") ERROR HERE[/COLOR]
End With
oBook.Save
oBook.Close
oExcel.Quit
End Function[CODE]