|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub test()
- With Sheets("2-4-9")
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = .range("a6:d" & r)
- For i = UBound(arr) To 1 Step -1
- If arr(i, 1) = 0 Or (InStr(arr(i, 1), ".") = 0 And Len(arr(i, 1))) > 4 Then
- hj = hj + arr(i, 4)
- Else
- arr(i, 4) = hj: hj = 0
- End If
- Next
- For i = 1 To UBound(arr) - 1
- If arr(i, 1) <> 0 Then
- If Len(arr(i, 1)) < 4 Or InStr(arr(i, 1), ".") Then
- u = UBound(Split(arr(i, 1), "."))
- For j = i + 1 To UBound(arr)
- If InStr(arr(j, 1), arr(i, 1) & ".") And UBound(Split(arr(j, 1), ".")) - u = 1 Then
- arr(i, 4) = arr(i, 4) + arr(j, 4)
- End If
- Next
- End If
- End If
- Next
- .range("a6:d" & r) = arr
- End With
- End Sub
复制代码 |
|