R
ryguy7272
Hello! I am trying to code a find/replace sub. The code below works:
Sub FindReplace()
ActiveSheet.Columns("A:B").Select
Selection.Replace What:="Chrysler Financial Services Americas LLC", _
Replacement:="Chrysler Financial Services", LookAt:=xlPart,
SearchOrder:= _
xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
Selection.Replace What:="General Motors Hourly Pension Fund", _
Replacement:="GM Hourly Pension Fund", LookAt:=xlPart, SearchOrder:= _
xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
‘etc
End Sub
However, the list of What:="" names will change frequently. This past week
there were 10 names; next week there may be many more. All names are listed
on a Sheet named ‘List of names to change’ (1 sheet). Basically, I am trying
to come up with a way of activating the Sheet named ‘List of names to
change’, selecting the variables (actually text/names, in column A) and then
replacing the variables (actually text/names, in column B…the same row as
Column A). By the way, all name replacements (all names will be in Column A
or Column B) will happen in sheets named ‘top 20 - AFTER’ or ‘top Industry -
AFTER’ (2 sheets). The names originally come from sheets named ‘top 20 -
BEFORE’ and ‘top Industry - BEFORE’.
Any ideas on how to do this?
Thanks so much,
Ryan---
Sub FindReplace()
ActiveSheet.Columns("A:B").Select
Selection.Replace What:="Chrysler Financial Services Americas LLC", _
Replacement:="Chrysler Financial Services", LookAt:=xlPart,
SearchOrder:= _
xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
Selection.Replace What:="General Motors Hourly Pension Fund", _
Replacement:="GM Hourly Pension Fund", LookAt:=xlPart, SearchOrder:= _
xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
‘etc
End Sub
However, the list of What:="" names will change frequently. This past week
there were 10 names; next week there may be many more. All names are listed
on a Sheet named ‘List of names to change’ (1 sheet). Basically, I am trying
to come up with a way of activating the Sheet named ‘List of names to
change’, selecting the variables (actually text/names, in column A) and then
replacing the variables (actually text/names, in column B…the same row as
Column A). By the way, all name replacements (all names will be in Column A
or Column B) will happen in sheets named ‘top 20 - AFTER’ or ‘top Industry -
AFTER’ (2 sheets). The names originally come from sheets named ‘top 20 -
BEFORE’ and ‘top Industry - BEFORE’.
Any ideas on how to do this?
Thanks so much,
Ryan---