excel - 运行多个“搜索和替换”
问题描述
我在工作中遇到了一些麻烦。这是一项新工作。
我得到了一个 Excel 表,其中一列中有 +3000 封电子邮件。所有这些电子邮件中都有某种类型的打字错误。
我们制定了大约 30 条规则(搜索和替换),可以帮助我们解决打字错误。
它可能是:
- 查找:gnail.com 替换为:gmail.com
- 查找:gmail.co 替换为:gmail.com
- 查找:autlook.com 替换为:outlook.com
有什么方法可以设置这些规则,以便 Excel 自动运行所有 30 个搜索和替换?
解决方案
修改并尝试:
Option Explicit
Sub Insert()
Dim LastRow As Long, i As Long
Dim str As String
With ThisWorkbook.Worksheets("Sheet1")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = 1 To LastRow
str = .Range("A" & i).Value
If InStr(1, str, "gnail.com") <> 0 Then
.Range("A" & i).Replace What:="gnail.com", Replacement:="gmail.com"
ElseIf InStr(1, str, "gmail.co") <> 0 Then
.Range("A" & i).Replace What:="gmail.co", Replacement:="gmail.com"
ElseIf InStr(1, str, "autlook.com") <> 0 Then
.Range("A" & i).Replace What:="autlook.com", Replacement:="outlook.com"
End If
Next i
End With
End Sub
推荐阅读
- python - Python从csv文件中读取如何仅从整数中删除引号
- regex - 使用 findText() 从 URL 获取路径元素
- javascript - 如何使用 setTimeout() 使字母立即出现?
- python-3.x - 我可以在 Pandas 数据帧上应用 Groupby 并计算所有列的平均值吗?
- asp.net-web-api - 将具有内部复杂对象的复杂对象传递给 GET Web API 端点
- android - 当单击另一个 CardView 时,CardView 会更改文本颜色
- javascript - Node JS .shift() 'ing 一个由 const 初始化的数组
- python - Python - 获取字符串中的 URL
- rxjs - 为什么 skipeWhile 不显示正确的结果?
- c++ - boost mpi 集合操作中的操作类型