excel - 在 VBA 中插入带变量的公式
问题描述
我正在尝试使用 VBA 将变量用于公式。我已经参考了如何将整数变量传递给 vba 公式这个问题,并尝试在我的 if 公式中实现它。=IF (startCell >0, startcell+confirmed, endcell+confirmed)
但我仍然不确定并遇到错误。
我的代码如下:
headerrow = 7
startCell = 8
endCell = 3
confirmed= 5
DDSS_Actual.Cells(headerrow + 3, 3).Formula = "=IF(" & startCell & ">" & endCell & ","& startCell & "+" &confirmed&", " & endCell & "+" &confirmed &")"
谢谢。
解决方案
你只需要在之前和之后放置空格&
这使得它
DDSS_Actual.Cells(headerrow + 3, 3).Formula = "=IF(" & startCell & ">" & endCell & "," & startCell & "+" & confirmed & "," & endCell & "+" & confirmed & ")"
推荐阅读
- android - zsh、flutter和android studio的问题
- javascript - Firebase 身份验证“auth/invalid-email”和“电子邮件地址格式错误”。
- nlp - 错误:AttributeError:模块“变压器”没有属性“TFBertModel”
- javascript - 使用 XMLHttpRequest 对 var 进行 get 请求,但也会创建回车
- android - Kotlin 应用程序中的地理位置按钮不可用
- isabelle - 如何在伊莎贝尔定理证明器中将值插入未知数?
- php - 循环序列化数组
- ruby-on-rails - Heroku 上的 Rails 应用似乎不需要 database.yml 文件
- java - 实现迭代器时出现 StackOverflowError
- python - 从 github 安装数据表找不到版本