|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub test()
- Dim sht As Worksheet
- arr = Sheets("sheet1").[a1].CurrentRegion
- ReDim brr(1 To UBound(arr), 1 To UBound(arr, 2))
- Set d = CreateObject("scripting.dictionary")
- For i = 2 To UBound(arr)
- If Len(arr(i, 1)) = 5 Then
- If Mid(arr(i, 1), 3, 1) > "6" Then Mid(arr(i, 1), 3, 1) = 6
- Else
- arr(i, 1) = Mid(arr(i, 1), 6, 5)
- End If
- If Not d.exists(arr(i, 1)) Then m = m + 1: d(arr(i, 1)) = m: brr(m, 1) = arr(i, 1)
- For j = 2 To UBound(arr, 2)
- brr(d(arr(i, 1)), j) = brr(d(arr(i, 1)), j) + arr(i, j)
- Next
- Next
- Application.DisplayAlerts = False
- For Each sht In Sheets
- If sht.Name <> "Sheet1" Then sht.Delete
- Next
- Application.DisplayAlerts = True
- For j = 2 To UBound(arr, 2) - 1
- ReDim crr(1 To m, 1 To 2)
- For i = 1 To m
- crr(i, 1) = brr(i, 1)
- crr(i, 2) = brr(i, j)
- Next
- Sheets.Add(after:=Sheets(Sheets.Count)).Name = arr(1, j)
- With ActiveSheet
- .[a1:b1] = Array("销售终端号", "销售金额")
- .[a2].Resize(m, 2) = crr
- End With
- Next
- 'Stop
- End Sub
复制代码
可否??? |
|