擅长:python、mysql、java
<p>我会将文本文件的内容复制到excel文件中的新工作表中,并将该工作表命名为“查找”。然后使用“文本到列”从第一行开始获取此新工作表前两列中的数据。</p>
<p>将以下代码粘贴到Excel中的模块中并运行:</p>
<pre><code>Sub Replacer()
Dim w1 As Worksheet
Dim w2 As Worksheet
'The sheet with the words from the text file:
Set w1 = ThisWorkbook.Sheets("Lookup")
'The sheet with all of the data:
Set w2 = ThisWorkbook.Sheets("Data")
For i = 1 To w1.Range("A1").CurrentRegion.Rows.Count
w2.Cells.Replace What:=w1.Cells(i, 1), Replacement:=w1.Cells(i, 2), LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Next i
End Sub
</code></pre>