|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub qs()
- Dim arr, i, dic, sht As Worksheet
- Application.DisplayAlerts = False
- For Each sht In Sheets
- If InStr(sht.Name, "待认领") Then sht.Delete
- Next
- Application.DisplayAlerts = True
- a = [{"待认领","未待认领"}]
- For i = 1 To UBound(a)
- Set sht = Sheets.Add
- sht.Name = a(i)
- Next i
- Set dic = CreateObject("scripting.dictionary")
- With Sheet7
- .Select
- arr = .[b2].CurrentRegion.Value
- End With
- For i = 4 To UBound(arr)
- dic(arr(i, 9)) = ""
- Next
- r = 1: rr = 1
- ReDim brr(1 To UBound(arr), 1 To 8): ReDim crr(1 To UBound(arr), 1 To 8)
- For Each k In dic.keys
- m = 0: n = 0
- For i = 4 To UBound(arr)
- If arr(i, 10) = "待认领" Then
- If arr(i, 9) = k Then
- m = m + 1
- For c = 1 To 8
- brr(m, c) = arr(i, c + 1)
- Next c
- End If
- ElseIf arr(i, 10) = "未待认领" Then
- If arr(i, 9) = k Then
- n = n + 1
- For c = 1 To 8
- crr(n, c) = arr(i, c + 1)
- Next c
- End If
- End If
-
- Next i
- With Sheet6
- If m > 0 Then
- .[c2].Value = "待认领": .[d2].Value = arr(2, 4): .[g2].Value = k
- .[b4].Resize(10, 8) = ""
- .[b4].Resize(m, 8) = brr
- rw = r + Sheets("待认领").Cells(Rows.Count, 1).End(3).Row
- .Rows("1:14").Copy Sheets("待认领").Range("a" & rw)
- End If
- If n > 0 Then
- .[c2].Value = "未待认领": .[d2].Value = arr(2, 4): .[g2].Value = k
- .[b4].Resize(10, 8) = ""
- .[b4].Resize(n, 8) = crr
- rww = rr + Sheets("未待认领").Cells(Rows.Count, 1).End(3).Row
- .Rows("1:14").Copy Sheets("未待认领").Range("a" & rww)
- End If
- End With
- Next k
- MsgBox "完成!"
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|