[英]Loops though columns to create sums
Hope you can help me. 希望您能够帮助我。 I have a list of quantities such as this: 我有一个这样的数量清单:
I need an autosum of everything that is above in the grey rows. 我需要上面灰色行中所有内容的自动求和。
So far my code: 到目前为止,我的代码:
Dim source As Range
Dim iCol As Long
Dim nCol As Long
Dim Cell As Range
Set source = Selection
For iCol = 1 To 5
With source.Columns(iCol)
If Cell.Font.Bold = False Then
i = i + Cell.Value
Else: Cell.Value = i
i = 0
End If
End With
Next iCol
Thanks in advance! 提前致谢!
I believe that's what you're after 我相信那是你所追求的
Dim source As Range, col As Range, cell As Range
Dim res As Double
Set source = Selection
With source
For Each col In .Columns
For Each cell In col.Cells
If cell.Font.Bold Then
cell.Value = res
res = 0
Else
res = res + cell.Value
End If
Next cell
Next col
End With
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.