我的文档中有 2 张纸(带有电话号码)。如果数字存在于工作表 1 中,我想从工作表 2 中删除该行。
我快到了(这是我第一次使用 VBA)。但谁能帮我完成最后一部分。
Sub CleanList()
Dim stopList As Range, cell1 As Range
Set stopList = Sheet1.Range("A1:A10000")
For Each cell1 In stopList
Dim fullList As Range, cell2 As Range
Set fullList = Sheet2.Range("A2:A10000")
For Each cell2 In fullList
If NumberFix(cell1.Value) = NumberFix(cell2.Value) Then
cell2.EntireRow.Delete
End If
Next cell2
Next cell1
End Sub
Private Function NumberFix(ByVal nr As String) As String
If Not nr.StartsWith("46") Then
nr = "46" + nr
End If
NumberFix = nr
End Function