Hello,
I have excel file with multiple tabs and I need to find text that contains "med ctr" or "med center" or "med cent" and replace it with "medical center" and this needs to be done on every sheet in the workbook. I found a couple of different codes but none of them works the way I need or I am getting error msg. Below is the latest code I tried.
Please help,
[FONT="]Sub[/FONT][FONT="] Multi_FindReplace()[/FONT]
[FONT="]Dim[/FONT][FONT="] sht [/FONT][FONT="]As[/FONT][FONT="] Worksheet[/FONT]
[FONT="]Dim[/FONT][FONT="] fndList [/FONT][FONT="]As[/FONT][FONT="] [/FONT][FONT="]Variant[/FONT]
[FONT="]Dim[/FONT][FONT="] rplcList [/FONT][FONT="]As[/FONT][FONT="] [/FONT][FONT="]Variant[/FONT]
[FONT="]Dim[/FONT][FONT="] x [/FONT][FONT="]As[/FONT][FONT="] [/FONT][FONT="]Long[/FONT]
[FONT="]fndList = Array("*MED CTR*", "*MED CENTER*", "*MED CENT*")[/FONT]
[FONT="]rplcList = Array("MEDICAL CENTER")[/FONT]
[FONT="]'Loop through each item in Array lists[/FONT]
[FONT="] [/FONT][FONT="]For[/FONT][FONT="] x = [/FONT][FONT="]LBound[/FONT][FONT="](fndList) [/FONT][FONT="]To[/FONT][FONT="] [/FONT][FONT="]UBound[/FONT][FONT="](fndList)[/FONT]
[FONT="] [/FONT][FONT="]'Loop through each worksheet in ActiveWorkbook[/FONT]
[FONT="] [/FONT][FONT="]For[/FONT][FONT="] [/FONT][FONT="]Each[/FONT][FONT="] sht [/FONT][FONT="]In[/FONT][FONT="] ActiveWorkbook.Worksheets[/FONT]
[FONT="] sht.Cells.Replace What:=fndList(x), Replacement:=rplcList(x), _[/FONT]
[FONT="] LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, _[/FONT]
[FONT="] SearchFormat:=False, ReplaceFormat:=False[/FONT]
[FONT="] [/FONT][FONT="]Next[/FONT][FONT="] sht[/FONT]
[FONT="] [/FONT]
[FONT="] [/FONT][FONT="]Next[/FONT][FONT="] x[/FONT]
[FONT="]End[/FONT][FONT="] [/FONT][FONT="]Sub
The last part is were I am getting an error msg.
Thanks
[/FONT]
I have excel file with multiple tabs and I need to find text that contains "med ctr" or "med center" or "med cent" and replace it with "medical center" and this needs to be done on every sheet in the workbook. I found a couple of different codes but none of them works the way I need or I am getting error msg. Below is the latest code I tried.
Please help,
[FONT="]Sub[/FONT][FONT="] Multi_FindReplace()[/FONT]
[FONT="]Dim[/FONT][FONT="] sht [/FONT][FONT="]As[/FONT][FONT="] Worksheet[/FONT]
[FONT="]Dim[/FONT][FONT="] fndList [/FONT][FONT="]As[/FONT][FONT="] [/FONT][FONT="]Variant[/FONT]
[FONT="]Dim[/FONT][FONT="] rplcList [/FONT][FONT="]As[/FONT][FONT="] [/FONT][FONT="]Variant[/FONT]
[FONT="]Dim[/FONT][FONT="] x [/FONT][FONT="]As[/FONT][FONT="] [/FONT][FONT="]Long[/FONT]
[FONT="]fndList = Array("*MED CTR*", "*MED CENTER*", "*MED CENT*")[/FONT]
[FONT="]rplcList = Array("MEDICAL CENTER")[/FONT]
[FONT="]'Loop through each item in Array lists[/FONT]
[FONT="] [/FONT][FONT="]For[/FONT][FONT="] x = [/FONT][FONT="]LBound[/FONT][FONT="](fndList) [/FONT][FONT="]To[/FONT][FONT="] [/FONT][FONT="]UBound[/FONT][FONT="](fndList)[/FONT]
[FONT="] [/FONT][FONT="]'Loop through each worksheet in ActiveWorkbook[/FONT]
[FONT="] [/FONT][FONT="]For[/FONT][FONT="] [/FONT][FONT="]Each[/FONT][FONT="] sht [/FONT][FONT="]In[/FONT][FONT="] ActiveWorkbook.Worksheets[/FONT]
[FONT="] sht.Cells.Replace What:=fndList(x), Replacement:=rplcList(x), _[/FONT]
[FONT="] LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, _[/FONT]
[FONT="] SearchFormat:=False, ReplaceFormat:=False[/FONT]
[FONT="] [/FONT][FONT="]Next[/FONT][FONT="] sht[/FONT]
[FONT="] [/FONT]
[FONT="] [/FONT][FONT="]Next[/FONT][FONT="] x[/FONT]
[FONT="]End[/FONT][FONT="] [/FONT][FONT="]Sub
The last part is were I am getting an error msg.
Thanks
[/FONT]