Hi
I have some code where I am deleting rows in Excel and using the Excel replace function however it doesnt seem to work. The code in red is where it fails.
Can anyone help me out on where its going wrong?
Thanks
Martin
Set XL = CreateObject("Excel.Application")
XL.Workbooks.Open ubImportFile
With XL
'.Application.Sheets.ActiveSheet
.Rows("1:2").Delete Shift:=xlUp
.Rows("2:2").Delete Shift:=xlUp
.Rows("1:1").Replace What:=" - ", Replacement:="-", LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
End With
I have some code where I am deleting rows in Excel and using the Excel replace function however it doesnt seem to work. The code in red is where it fails.
Can anyone help me out on where its going wrong?
Thanks
Martin
Set XL = CreateObject("Excel.Application")
XL.Workbooks.Open ubImportFile
With XL
'.Application.Sheets.ActiveSheet
.Rows("1:2").Delete Shift:=xlUp
.Rows("2:2").Delete Shift:=xlUp
.Rows("1:1").Replace What:=" - ", Replacement:="-", LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
End With