VBA变量里面的公式 [英] VBA Variable inside formula

查看:141
本文介绍了VBA变量里面的公式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码

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

用一个变量total替换90,我尝试过但是没有工作:

I want to replace 90 with a variable "total", I tried this but didn't work:

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

为您提供帮助

推荐答案

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

you need to remove the spaces in the bracket.

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

这篇关于VBA变量里面的公式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆