|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
arr = ActiveSheet.UsedRange
Set d1 = CreateObject("scripting.dictionary")
Set d2 = CreateObject("scripting.dictionary")
For j = 2 To UBound(arr)
If Len(arr(j, 1)) > 0 Then
d1(arr(j, 1)) = ""
End If
If Len(arr(j, 2)) > 0 Then
d2(arr(j, 2)) = ""
End If
Next j
If d1.Count > 0 Then
Cells(2, 4).Resize(d1.Count) = WorksheetFunction.Transpose(d1.keys)
End If
arr1 = d2.keys
a = d1.Count + 2
For j = 0 To UBound(arr1)
If d1.exists(arr1(j)) Then
Columns(4).Find(arr1(j), lookat:=xlWhole).Offset(0, 1) = arr1(j)
Else
Cells(a, "e") = arr1(j)
a = a + 1
End If
Next j
Application.ScreenUpdating = True
End Sub |
|