Sub xLator2()
Dim s1 As Worksheet, s2 As Worksheet
Dim N As Long, i As Long
Dim from(), too()
Set s1 = Sheets("Sheet1") ' contains the data
Set s2 = Sheets("Sheet2") ' contains the translation table
s2.Activate
N = Cells(Rows.Count, 1).End(xlUp).Row
ReDim from(1 To N)
ReDim too(1 To N)
For i = 1 To N
from(i) = Cells(i, 1).Value
too(i) = Cells(i, 2).Value
Next i
s1.Activate
For i = LBound(from) To UBound(from)
Cells.Replace What:=from(i), Replacement:=too(i)
Next i
End Sub
我正在使用上面的代码在下面提到的工作表中查找和替换多个单词(“ Column A Sheet1”中的单词与“ Column B Sheet 2”中的单词):
https://docs.google.com/spreadsheets/d/15TRLccDr_EAR8s78u-WGSkGpAecBf42_lhRkjCev_WE/edit?usp=sharing
但是,当我在另一个工作表(如下所述)中将其应用于另一个数据时,代码将失败,即我在工作表1中得到了失真的单词:
https://docs.google.com/spreadsheets/d/14ba9pQDjMPWJd4YFpGffhtVcHxml0LdUUVQ0prrOEUY/edit?usp=sharing
请帮帮我,以便我可以将“ A列Sheet1”中的单词替换为“ B列Sheet2”中的单词
注意:上面的链接已经给出了Google电子表格,但是我在Excel 2007工作表中遇到了问题。
我要求您通过提供完整的修订代码来帮助我,因为我在VBA中表现不佳