excel vba删除表一与表二重复内容(二个表都删除)
答案:1 悬赏:0 手机版
解决时间 2021-11-25 17:46
- 提问者网友:疯孩纸
- 2021-11-25 01:42
excel vba删除表一与表二重复内容(二个表都删除)
最佳答案
- 五星知识达人网友:鱼芗
- 2021-11-25 03:14
Sub RmSame()
Dim A As Range, B As Range
For Each A In Sheets(1).Range("A23:J70")
For Each B In Sheets(2).Range("A2:J50")
If A.Value = B.Value Then A.Value = "": B.Value = ""
Next
Next
End Sub追问A范围修改为("A2:J2000")
B范围修改为("A5:J3000")
删除时间过长,好卡追答试试用Find方法是否可以快一些
Sub RmSame()
Dim A As Range, B As Range
For Each A In Sheets(1).Range("A23:J70")
With Sheets(2).Range("A2:J50")
If A.Value <> "" Then
Set B = .Find(A.Value, LookIn:=xlValues, LookAt:=xlWhole)
If Not B Is Nothing Then
Do
B.Value = ""
Set B = .FindNext(B)
Loop While Not B Is Nothing
A.Value = ""
End If
End If
End With
Next
End Sub
Dim A As Range, B As Range
For Each A In Sheets(1).Range("A23:J70")
For Each B In Sheets(2).Range("A2:J50")
If A.Value = B.Value Then A.Value = "": B.Value = ""
Next
Next
End Sub追问A范围修改为("A2:J2000")
B范围修改为("A5:J3000")
删除时间过长,好卡追答试试用Find方法是否可以快一些
Sub RmSame()
Dim A As Range, B As Range
For Each A In Sheets(1).Range("A23:J70")
With Sheets(2).Range("A2:J50")
If A.Value <> "" Then
Set B = .Find(A.Value, LookIn:=xlValues, LookAt:=xlWhole)
If Not B Is Nothing Then
Do
B.Value = ""
Set B = .FindNext(B)
Loop While Not B Is Nothing
A.Value = ""
End If
End If
End With
Next
End Sub
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯