没系统的看过书,不知道合并单元格怎么搞,不过我知道合并单元格的值是在第一个单元格里的,所以遍历A列,
不是空格
记录行数(用来填答案)
重置求和数为所在行的B列
是空格,把数据加到求和数里
所在行的B列加到求和数里
把答案铁道记录行数的D列
写成代码大概就是
sub demo()
dim rowNum as int,sum as double,rng as range
for each rng in range([A2],[b2].end(xldown).offset(0,-1))
if rng=empty then
sum=sum+rng.offset(0,2)
else
if rowNum>0 then
cells(rowNum,5)=sum
end if
sum=rng.offset(0,2)
rowNum=rng.row()
end if
next rng
cells(rowNum,5)=sum
end sub
追问提示出错了
追答谢谢你的追问 那我调试一下
Sub demo()
Dim rowNum As Integer, sum As Double, rng As Range
For Each rng In Range([A2], [b2].End(xlDown).Offset(0, -1))
If rng = Empty Then
sum = sum + rng.Offset(0, 2)
Else
If rowNum > 0 Then
Cells(rowNum, 5) = sum
End If
sum = rng.Offset(0, 2)
rowNum = rng.Row()
End If
Next rng
Cells(rowNum, 5) = sum
End Sub