我有一个包含多张纸的大型Excel文件。它们都具有相同的结构。 我需要在所有工作表的E栏中将“old1”和“old2”替换为“new1”和“new2”。 这就是我想出的:
`Dim sht As Worksheet
Dim fndList As Variant
Dim rplcList As Variant
Dim x As Long
fndList = Array("old1", "old2")
rplcList = Array("new1", "new2")
'Loop through each item in Array lists
For x = LBound(fndList) To UBound(fndList)
'Loop through each worksheet in ActiveWorkbook
For Each sht In ActiveWorkbook.Worksheets
sht.Range("E:E").Replace What:=fndList(x), Replacement:=rplcList(x), _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, _
SearchFormat:=False, ReplaceFormat:=False
Next sht
Next x`
不幸的是,虽然这取代了所有单元格中的文本,而不仅仅是E:E。 我该怎么办?提前致谢! 恩里科