|
因不确定你这个合并单元格一定都是8行,所以只能用单元格取数了,否则用数组速度能快不少。
Sub test()
With Sheet1
zh = .[B2].End(xlDown).Row
i = 3
Do While i < zh
If .Cells(i, 1) <> "" Then
hyje = 0: hysl = 0: dj = 0
hbl = Cells(i, 1).MergeArea.Rows.Count
ksh = i: jsh = i + hbl - 1
If (.Cells(ksh, "c") + .Cells(ksh, "e")) <> 0 Then dj = (.Cells(ksh, "d") + .Cells(ksh, "f")) / (.Cells(ksh, "c") + .Cells(ksh, "e"))
For j = ksh + 1 To jsh
.Cells(j, "m") = .Cells(j, "l") * dj
hyje = hyje + .Cells(j, "m")
hysl = hysl + .Cells(j, "l")
Next
.Cells(ksh, "l") = hysl
.Cells(ksh, "m") = hyje
.Cells(ksh, "g") = .Cells(ksh, "i") + .Cells(ksh, "l")
.Cells(ksh, "h") = .Cells(ksh, "j") + .Cells(ksh, "m")
.Cells(ksh, "o") = .Cells(ksh, "c") + .Cells(ksh, "e") - .Cells(ksh, "g")
.Cells(ksh, "p") = .Cells(ksh, "d") + .Cells(ksh, "f") - .Cells(ksh, "h")
End If
i = jsh + 1
Loop
End With
End Sub
|
评分
-
1
查看全部评分
-
|