我有一张产品代码的电子表格。我需要更改其中的大约200个。
下面的代码删除另一个工作表上单元格中的所有数据,而不是在第二列中用新的产品代码替换它。
Sub Multi_FindReplace()
Dim sht As Worksheet
Dim fndList As Integer
Dim rplcList As Integer
Dim tbl As ListObject
Dim myArray As Variant
Set tbl = Worksheets("Sheet4").ListObjects("Table1")
Set TempArray = tbl.DataBodyRange
myArray = Application.Transpose(TempArray)
fndList = 1
rplcList = 2
For x = LBound(myArray, 1) To UBound(myArray, 2)
For Each sht In ActiveWorkbook.Worksheets
If sht.Name <> tbl.Parent.Name Then
sht.Cells.Replace What:=myArray(fndList, x), Replacement:=myArray(rplcList, x), _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, _
SearchFormat:=False, ReplaceFormat:=False
End If
Next sht
Next x
End Sub
1条答案
按热度按时间m2xkgtsf1#
试试这个: