|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub test()
- Dim r%, i%
- Dim arr, brr
- With Worksheets("sheet1")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- arr = .Range("a1:a" & r)
- ReDim brr(1 To UBound(arr), 1 To 1)
- For i = 4 To UBound(arr)
- If .Cells(i, 1).MergeCells Then
- If .Cells(i, 1).MergeArea.Cells(1, 1).Address = .Cells(i, 1).Address Then
- hs = .Cells(i, 1).MergeArea.Rows.Count
- For j = 1 To hs
- brr(i + j - 1, 1) = Application.Round(arr(i, 1) / hs, 2)
- Next
- End If
- Else
- brr(i, 1) = arr(i, 1)
- End If
- Next
- .Range("c1").Resize(UBound(brr), UBound(brr, 2)) = brr
-
- End With
- End Sub
复制代码 |
|