我有一个公式,可以根据项目要计算的月数创建x列数据。我正在尝试公式化宏以将公式输入到单元格中以计算单元格。它需要添加的列数将因项目而异。 我已经尝试过一些脚本,但是对如何继续执行却感到困惑,但仍在尝试。
Sub Totals()
Dim SumRange As Integer
Dim AddCell As Range
Sheets("Tracking (DAYS)").Select
Sheets("Tracking (DAYS)").Range("E4").Select
Do Until IsEmpty(ActiveCell.Offset(-1, 0))
Set AddCell = ActiveCell.Offset(0, 3)
Range("E4").FormulaR1C1 = _
"=IF([@[Resource Name]]="""",""""," & AddCell & ")"
Loop
End Sub
答案 0 :(得分:0)
我的最佳猜测解决方案:
Sub Totals()
Lc = Sheets("Tracking (DAYS)").Cells(3, 999).End(xlToLeft).Column
Sheets("Tracking (DAYS)").Range("E4").FormulaR1C1 = _
"=SUMIF(R3C8:R3C" & Lc & ",""*(Forecast) Calendar"",R4C8:R4C" & Lc & ")"
End Sub