|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub test()
Dim brr()
Set d = CreateObject("scripting.dictionary")
arr = Worksheets("内容").Range("a1").CurrentRegion
For j = 2 To UBound(arr)
If Not d.exists(arr(j, 1)) Then
ReDim brr(1 To UBound(arr) - 1, 1 To UBound(arr, 2))
For i = 1 To UBound(arr, 2)
brr(1, i) = arr(j, i)
Next i
d(arr(j, 1)) = brr
Else
crr = d(arr(j, 1))
For i = 1 To UBound(crr)
If Len(crr(i, 1)) = 0 Then Exit For
Next
For x = 1 To UBound(arr, 2)
crr(i, x) = arr(j, x)
Next x
d(arr(j, 1)) = crr
End If
Next j
Application.ScreenUpdating = False
Sheets("模板").Copy
With ActiveWorkbook
For Each k In d.keys
Sheets("模板").UsedRange.Offset(1).ClearContents
crr = d(k)
For i = 1 To UBound(crr)
If Len(crr(i, 1)) = 0 Then Exit For
Next
Sheets("模板").[a2].Resize(i, UBound(crr, 2)) = crr
.SaveAs ThisWorkbook.Path & "\" & k & ".xlsx"
Next k
.Close
End With
Application.ScreenUpdating = True
End Sub
|
|