我想搜索显示“total”的列,并且需要开始在“total”列旁边添加值
文本“total”在列“o”中,值在列p,q,r,s中。
我需要将值总结为1265 + 1789 + 2099.25 ...并在任何单元格中显示输出总和。
请帮忙
答案 0 :(得分:0)
所以这就像是:
Dim r As Long
Dim c As Long
Dim tot As Double
Dim fnd As Boolean
Dim cellTx As String
tot = 0
fnd = False
For r = 1 To ActiveSheet.UsedRange.Rows.Count
For c = 1 To ActiveSheet.UsedRange.Columns.Count
cellTx = ActiveSheet.UsedRange(r, c).Value
If fnd Then
If IsNumeric(cellTx) Then tot = tot + Val(cellTx)
Else
If cellTx = "total" Then fnd = True
End If
Next
If fnd Then Exit For
Next
然后将总数存储在tot
变量中。此代码可能需要一些调试和错误处理