|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub test()
- Dim r&, i&
- Dim arr, brr
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- With Worksheets("数据源")
- .AutoFilterMode = False
- r = .Cells(.Rows.Count, 2).End(xlUp).Row
- c = .Cells(1, .Columns.Count).End(xlToLeft).Column
- arr = .Range("a2").Resize(r - 1, c)
- End With
- ReDim brr(1 To UBound(arr), 1 To 23)
- For i = 1 To UBound(arr)
- For j = 2 To 12
- brr(i, j - 1) = arr(i, j)
- Next
- For j = 15 To 69 Step 6
- For k = 1 To 5
- brr(i, k + 12) = brr(i, k + 12) + arr(i, j + k)
- brr(i, 12) = brr(i, 12) + arr(i, j + k)
- Next
- x = 0
- Select Case arr(i, j)
- Case "外观"
- x = 18
- Case "组装"
- x = 19
- Case "包装"
- x = 20
- Case "机能"
- x = 21
- End Select
- If x > 0 Then
- For k = 1 To 5
- brr(i, x) = brr(i, x) + arr(i, j + k)
- Next
- End If
- brr(i, 22) = arr(i, 13)
- brr(i, 23) = arr(i, 14)
- Next
- Next
- With Worksheets("统计")
- .UsedRange.Offset(2, 0).Clear
- .Columns(2).NumberFormatLocal = "@"
- .Columns(23).NumberFormatLocal = "0.00"
- With .Range("a3").Resize(UBound(brr), UBound(brr, 2))
- .Value = brr
- .Borders.LineStyle = xlContinuous
- With .Font
- .Name = "微软雅黑"
- .Size = 11
- End With
- End With
- End With
- End Sub
复制代码 |
|