VBA可变内部公式

我有以下代码

ActiveCell.FormulaR1C1 = "=COUNTIF(R[-54]C[-14]:R[-54]C[90],RC[-4])" 

我想用一个variables“total”replace90,我试过但没有工作:

 Dim total as Integer total=Inputbox("Enter a number") ActiveCell.FormulaR1C1 = "=COUNTIF(R[-54]C[-14]:R[-54]C[ " & total & " ],RC[-4])" 

Ty为您提供帮助

您需要删除括号中的空格。

 Dim total as Integer total=Inputbox("Enter a number") ActiveCell.FormulaR1C1 = "=COUNTIF(R[-54]C[-14]:R[-54]C[" & total & "],RC[-4])"