我有以下代码
ActiveCell.FormulaR1C1 = "=COUNTIF(R[-54]C[-14]:R[-54]C[90],RC[-4])"
我想用变量“total”替换90,我试过这个但是没有用:
Dim total as Integer
total=Inputbox("Enter a number")
ActiveCell.FormulaR1C1 = "=COUNTIF(R[-54]C[-14]:R[-54]C[ " & total & " ],RC[-4])"
Ty为你提供帮助
答案 0 :(得分:2)
您需要删除括号中的空格。
Dim total as Integer
total=Inputbox("Enter a number")
ActiveCell.FormulaR1C1 = "=COUNTIF(R[-54]C[-14]:R[-54]C[" & total & "],RC[-4])"