replace function in Excel

mcmuppet

New member
Local time
Today, 10:09
Joined
Dec 1, 2011
Messages
7
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
 

Users who are viewing this thread

Back
Top Bottom