问题
I receive a quarterly data set where I need to make some general changes to the data. The changes are routinely the same and I want to use a macro to change them in one fell swoop rather than find/replace manually. I found a script that saves my data as an array and then searches the entire workbook. It works BUT I only want it to find/replace in a specific range. I've tried many times to alter the code, but I am unable to. I don't even know if this is the best way to accomplish it - very open to all feedback!
Sub Multi_FindReplace()
Dim sht As Worksheet
Dim fndList As Variant
Dim rplcList As Variant
Dim x As Long
fndList = Array("Unnamed Rd", "526-566 Stanford UniversityLagunita Dr", "Social Science Parking Structure")
rplcList = Array("Departure Access Rd", "526-566 Lagunita Dr", "4139 Campus Dr")
For x = LBound(fndList) To UBound(fndList)
For Each sht In ActiveWorkbook.Worksheets
sht.Cells.Replace What:=fndList(x), Replacement:=rplcList(x), _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, _
SearchFormat:=False, ReplaceFormat:=False
Next sht
Next x
End Sub
来源:https://stackoverflow.com/questions/41291498/vba-find-replace-using-array-for-cell-range