matratus34
Board Regular
- Joined
- Nov 21, 2013
- Messages
- 74
Hi - I've got a workbook with around 50 data tabs which are updated monthly and I need to do a find and replace on around 40 different values each time the data is refreshed. (the SPV values)
e.g
find ABC replace with XYZ
find DER replace with NG1
find FOR replace with ZG1
x40
I've got a tab with all my old and new values stored ("SPVList")
I've written a macro that will loop down my old and new values and find and replace on each tab but this also amends the values on my "SPVList" tab which I need to keep intact for the next time I run the macro.
Any help with the code so that it changes the values on all tabs apart from the "SPVList" tab would be greatly appreciated.
Sub SPV_Changes()
'Changes SPV code to parent DOH code
Worksheets("SPVList").Select
'Ask if user want to change the DOH codes - if not exit macro
chgSPV = MsgBox("Do you want to amend SPV Codes?", vbYesNo)
If chgSPV = vbNo Then Exit Sub
'Loop through rows containing SPV codes and replace with parent codes
i = 6
Do While Not IsEmpty(Cells(i, 2))
Selection.Replace What:=Cells(i, 2).Value, Replacement:=Cells(i, 3).Value, LookAt:=xlWhole, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
i = i + 1
Loop
End Sub
Thanks Guys
e.g
find ABC replace with XYZ
find DER replace with NG1
find FOR replace with ZG1
x40
I've got a tab with all my old and new values stored ("SPVList")
I've written a macro that will loop down my old and new values and find and replace on each tab but this also amends the values on my "SPVList" tab which I need to keep intact for the next time I run the macro.
Any help with the code so that it changes the values on all tabs apart from the "SPVList" tab would be greatly appreciated.
Sub SPV_Changes()
'Changes SPV code to parent DOH code
Worksheets("SPVList").Select
'Ask if user want to change the DOH codes - if not exit macro
chgSPV = MsgBox("Do you want to amend SPV Codes?", vbYesNo)
If chgSPV = vbNo Then Exit Sub
'Loop through rows containing SPV codes and replace with parent codes
i = 6
Do While Not IsEmpty(Cells(i, 2))
Selection.Replace What:=Cells(i, 2).Value, Replacement:=Cells(i, 3).Value, LookAt:=xlWhole, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
i = i + 1
Loop
End Sub
Thanks Guys
Last edited: