我有一份报告,我试图获取动态行数的总和以生成小计。
If Cells(s, 1).Value = "start" Then
If Cells(r, 1).Value = "subtotal" Then
'Set the Monthly Subtotal Formulas
Cells(r, 44) = "=SUM(AR" & Trim(Str(s)) & ":AR" & Trim(Str(r - 1)) & ")"
Cells(r, 46) = "=SUM(AT" & Trim(Str(s)) & ":AT" & Trim(Str(r - 1)) & ")"
'Set the Weekly Subtotal Formulas
Cells(r, 48) = "=SUM(AV" & Trim(Str(s)) & ":AV" & Trim(Str(r - 1)) & ")"
Cells(r, 52) = "=SUM(AZ" & Trim(Str(s)) & ":AZ" & Trim(Str(r - 1)) & ")"
'Set the Daily Subtotal Formulas
Cells(r, 54) = "=SUM(BB" & Trim(Str(s)) & ":BB" & Trim(Str(r - 1)) & ")"
Cells(r, 56) = "=SUM(BD" & Trim(Str(s)) & ":BD" & Trim(Str(r - 1)) & ")"
'Set the Hourly Formulas
Cells(r, 60) = "=SUM(BH" & Trim(Str(s)) & ":BH" & Trim(Str(r - 1)) & ")"
Cells(r, 62) = "=SUM(BJ" & Trim(Str(s)) & ":BJ" & Trim(Str(r - 1)) & ")"
Cells(r, 1) = ""
End If
Cells(s, 1) = ""
End If
基本上,每个工作组都在单元格值“开始”和“小计”内。如何找到“s”或行号并在公式中使用它?