Hello,
I'm having trouble with a "find & replace" formula in VBA. Namely, I have 2 columns, Column "BH" where it will find current value and Column "BI" where I noted what the found value should be replaced to. However, both are 4 digit numbers and start with a 0. So, I'd like to replace "0001" with "0002", but "0001" replaces with a "2" omitting zeroes. Zeroes must be included in the replacement value.
Here is the code:
Thanks much...
I'm having trouble with a "find & replace" formula in VBA. Namely, I have 2 columns, Column "BH" where it will find current value and Column "BI" where I noted what the found value should be replaced to. However, both are 4 digit numbers and start with a 0. So, I'd like to replace "0001" with "0002", but "0001" replaces with a "2" omitting zeroes. Zeroes must be included in the replacement value.
Here is the code:
Code:
Private Sub Reclass_Accounts()
Dim fndvlue As Variant
Dim rplcvlue As Variant
Dim x As Long
fndvlue = Array(Sheets("Settings").Range("BH2").Value, Sheets("Settings").Range("BH3").Value, _
Sheets("Settings").Range("BH4").Value, Sheets("Settings").Range("BH5").Value)
rplcvlue = Array(Sheets("Settings").Range("BI2").Value, Sheets("Settings").Range("BI3").Value, _
Sheets("Settings").Range("BI4").Value, Sheets("Settings").Range("BI5").Value)
'Loop through each item in Array
For x = LBound(fndvlue) To UBound(fndvlue)
'Reclass Actuals
Range("E3").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Replace What:=fndvlue(x), Replacement:=rplcvlue(x), LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=True, _
ReplaceFormat:=True
Next x
End Sub
Thanks much...