如何在Excel中查找和replace多个值?

例如,我有一个18000域的列和另一个210.000域的列表,这18000域可以find。 我需要做像CTRL + H,查找和replacesmth,并在查找字段中,我需要添加整个18000个域名:像* domain1.com *,* domain2.com *,* domain3.com *,并replace他们与空白空间。 试图用查找和replace从Excel中,但它不能在查找字段中添加多个值。 我怎样才能做到多值?

VBA解决scheme

您将需要更改两个工作表参考(数据和编辑表)data = source,edit = destination。 我也将replacestring设置为一个variables,所以你可以根据需要从一个空string中改变。

如果你需要任何其他的逻辑(比如在比较之前修改string,或者改变string大小写比较),代码应该很容易调整。

希望这可以帮助。

Sub ReplaceValues() Dim dataSht As Worksheet Dim editSht As Worksheet Dim dataRange As Range Dim dataColumn As Long Dim editColumn As Long Dim dataEndRow As Long Dim editEndRow As Long 'sheet that holds all the values we want to find Set dataSht = Sheet2 'sheet we want to edit Set editSht = Sheet1 Dim replaceValue As String 'replace value is empty string replaceValue = "" 'set the column of the data sheet to A dataColumn = 1 'set the colmun of the sheet to edit to A editColumn = 1 dataEndRow = dataSht.Cells(dataSht.Rows.count, dataColumn).End(xlUp).Row editEndRow = editSht.Cells(editSht.Rows.count, editColumn).End(xlUp).Row 'this is the range of the data that we're looking for Set dataRange = dataSht.Range(dataSht.Cells(1, dataColumn), dataSht.Cells(dataEndRow, dataColumn)) Dim count As Long Dim val As String For i = 1 To editEndRow val = editSht.Cells(i, editColumn).Value count = Application.WorksheetFunction.CountIf(dataRange, val) If count > 0 And Trim(val) <> "" Then editSht.Cells(i, editColumn).Value = replaceValue End If Next i End Sub 

您可以使用通配符查找/replace。 所以在你的情况下,你应该可以使用类似的东西

domain*find what字段,并在Replace字段中没有