|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 zhangmy66 于 2024-9-14 23:30 编辑
sub test()
Dim arr, i, dic, sht As Worksheet, st As Worksheet
Dim s, k, ar, sr
Set sht = ActiveSheet
Set dic = CreateObject("scripting.dictionary")
Application.ScreenUpdating = False
arr = ActiveSheet.UsedRange.Value
For i = 6 To UBound(arr)
s = arr(i, 9) & "-" & arr(i, 7)
If Len(s) > 1 Then
If Not dic.exists(s) Then
dic(s) = ""
End If
End If
Next
For Each k In dic.keys
sht.Copy after:=Sheets(Sheets.Count)
Set st = ActiveSheet
st.Name = k
ar = st.UsedRange.Value
For i = UBound(ar) To 4 Step -1
s = arr(i, 9) & "-" & arr(i, 7)
If Len(s) > 1 Then
If s <> k Then
Rows(i).Delete
End If
End If
Next
[n2].Select
Next
Application.ScreenUpdating = True
Set dic = Nothing: Set sht = Nothing: Set sr = Nothing
End Sub
|
|