|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
参与一下。。。- Sub ykcbf() '//2024.2.9
- Set d = CreateObject("scripting.dictionary")
- Set d1 = CreateObject("scripting.dictionary")
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Dim tm: tm = Timer
- arr = Sheets("密码").UsedRange
- For i = 2 To UBound(arr)
- d1(arr(i, 1)) = arr(i, 2)
- Next
- Set sh = ThisWorkbook.Sheets("数据")
- For Each sht In Sheets
- If sht.Name <> "密码" And sht.Name <> sh.Name Then
- sht.Delete
- End If
- Next
- arr = sh.UsedRange
- For i = 2 To UBound(arr)
- s = arr(i, 2)
- If Not d.Exists(s) Then
- Set d(s) = CreateObject("scripting.dictionary")
- End If
- d(s)(i) = i
- Next i
- For Each k In d.keys
- sh.Copy after:=Sheets(Sheets.Count)
- Set sht = Sheets(Sheets.Count)
- m = 0
- ReDim brr(1 To d(k).Count, 1 To 4)
- With sht
- .Name = k
- .DrawingObjects.Delete
- For Each kk In d(k).keys
- m = m + 1
- For j = 1 To UBound(arr, 2)
- brr(m, j) = arr(kk, j)
- Next
- Next
- .[a2].Resize(m, 4) = brr
- .Protect d1(k), UserInterfaceOnly:=True
- End With
- Next k
- sh.Activate
- Set d = Nothing
- Application.DisplayAlerts = True
- Application.ScreenUpdating = True
- MsgBox "共用时:" & Format(Timer - tm) & "秒!"
- End Sub
复制代码
|
|