|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub a()
Dim arr, brr(1 To 999, 1 To 18), i%, j%, m%, d, sh As Worksheet, k, x%, t
Set d = CreateObject("Scripting.Dictionary")
Application.DisplayAlerts = False
Application.ScreenUpdating = False
For Each sh In Sheets
If sh.Name <> "工资汇总表" Then
sh.Delete
End If
Next
Application.DisplayAlerts = True
arr = Sheet1.[a1].CurrentRegion
For i = 2 To UBound(arr)
d(arr(i, 2)) = ""
Next
k = d.keys
Set d = Nothing
For x = 0 To UBound(k)
For i = 2 To UBound(arr)
If arr(i, 2) = k(x) Then
m = m + 1
t = t + 1
For j = 2 To 18
brr(m, 1) = t
brr(m, j) = arr(i, j)
brr(m + 1, 1) = ""
brr(m + 1, j) = ""
Next
m = m + 1
End If
Next
Sheets.Add(after:=Sheets(Sheets.Count)).Name = k(x)
Sheet1.[a1:r1].Copy [a1]
[a2].Resize(m, 18) = brr
m = 0
t = 0
Next
Application.ScreenUpdating = True
End Sub
|
|