excel vba快速删除重复项
AF666:AO866区域11.....先将区域1还原单元格为无色A39:J1038区域22.....区域1与区域2有内容重复时,将区域1重复单元填充为紫色,删除区域2重...
AF666:AO866区域1
1.....先将区域1还原单元格为无色
A39:J1038区域2
2.....区域1与区域2有内容重复时,将区域1重复单元填充为紫色,删除区域2重复单元内容 展开
1.....先将区域1还原单元格为无色
A39:J1038区域2
2.....区域1与区域2有内容重复时,将区域1重复单元填充为紫色,删除区域2重复单元内容 展开
2个回答
展开全部
Sub xx()
Set d1 = CreateObject("scripting.dictionary")
Set d2 = CreateObject("scripting.dictionary")
With [AF666:AO866]
.Interior.ColorIndex = xlNone
For i = 1 To .Count
d1(.Item(i).Text) = ""
Next
End With
With [A39:J1038]
For i = 1 To .Count
If d1.exists(.Item(i).Text) Then
d2(.Item(i).Text) = ""
.Item(i).ClearContents
End If
Next
End With
With [AF666:AO866]
For i = 1 To .Count
If d2.exists(.Item(i).Text) Then
.Item(i).Interior.ColorIndex = 7
End If
Next
End With
End Sub
追问
现在区域1的空单元变为紫色了
先将区域1还原单元为无色,(区域1有部分单元或空单元有颜色,所以先还原为无色)
2。删除区域2相同的(见红色示)
3。区域1相同的填充紫色(见紫色示)
追答
Sub xx()
Set d1 = CreateObject("scripting.dictionary")
Set d2 = CreateObject("scripting.dictionary")
With [AF666:AO866]
.Interior.ColorIndex = xlNone
For i = 1 To .Count
If .Item(i) <> "" Then d1(.Item(i).Text) = ""
Next
End With
With [A39:J1038]
For i = 1 To .Count
If d1.exists(.Item(i).Text) Then
d2(.Item(i).Text) = ""
.Item(i).ClearContents
End If
Next
End With
With [AF666:AO866]
For i = 1 To .Count
If d2.exists(.Item(i).Text) Then
.Item(i).Interior.ColorIndex = 7
End If
Next
End With
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询