|
- Sub test0() '拼凑
-
- Dim data, results, sum_(), t(2) As Double
- Dim i As Long, j As Long, k As Long
- Dim p As Long, cnt As Long
-
- data = Range("BN3").CurrentRegion.Offset(1).Value
- results = Range("B3").CurrentRegion.Offset(1).Value
- ReDim sum_(1 To UBound(data, 2))
-
- For j = LBound(sum_) To UBound(sum_)
- sum_(j) = t
- Next
-
- p = 5
- For i = 1 To UBound(data) - 1
- cnt = cnt + 1
- For j = 1 To UBound(data, 2)
- results(cnt, p + j) = data(i, j)
- For k = 0 To UBound(t)
- sum_(j)(k) = sum_(j)(k) + Val(data(i, j))
- Next
- Next
- If InStr(results(cnt + 1, 3), "小计") Then
- cnt = cnt + 1
- For j = LBound(sum_) To UBound(sum_)
- results(cnt, p + j) = sum_(j)(0)
- sum_(j)(0) = 0
- Next
- End If
- If InStr(results(cnt + 1, 2), "合计") Then
- cnt = cnt + 1
- For j = LBound(sum_) To UBound(sum_)
- results(cnt, p + j) = sum_(j)(1)
- sum_(j)(1) = 0
- Next
- End If
- If InStr(results(cnt + 1, 1), "总计") Then
- cnt = cnt + 1
- For j = LBound(sum_) To UBound(sum_)
- results(cnt, p + j) = sum_(j)(2)
- sum_(j)(2) = 0
- Next
- End If
- If cnt = UBound(results) - 1 Then Exit For
- Next
- Range("B4").Resize(UBound(results), UBound(results, 2)) = results
-
- Beep
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|