P
Paige
If you are doing find/replace in VBA and having issues with the code
replacing within the workbook versus the specified range in your code (which
is a known problem), then try this. First do a 'dummy' find, then do your
desired find/replace. For example:
'Your 'dummy' find:
Dim r As Range
Set r = Worksheets("Sheet1").Range("G3:G65").Find(What:="ZORRO",
LookIn:=xlFormulas)
‘Then do your ‘real’ find/replace, such as:
Worksheets("Sheet1").Range("G3:G65").Select
Selection.Replace What:=" ", Replacement:="", LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False,
ReplaceFormat:=False
This resets the 'Within' field in Excel's Find and Replace box to 'Sheet',
so your code will do the find/replace only within the specified range. This
has been working for me so wanted to post in case it might help others.
Thanks.
replacing within the workbook versus the specified range in your code (which
is a known problem), then try this. First do a 'dummy' find, then do your
desired find/replace. For example:
'Your 'dummy' find:
Dim r As Range
Set r = Worksheets("Sheet1").Range("G3:G65").Find(What:="ZORRO",
LookIn:=xlFormulas)
‘Then do your ‘real’ find/replace, such as:
Worksheets("Sheet1").Range("G3:G65").Select
Selection.Replace What:=" ", Replacement:="", LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False,
ReplaceFormat:=False
This resets the 'Within' field in Excel's Find and Replace box to 'Sheet',
so your code will do the find/replace only within the specified range. This
has been working for me so wanted to post in case it might help others.
Thanks.