excel - Excel VBA .Formula - 添加对单元格的绝对引用的语法错误
问题描述
我在这个 VBA 代码中有一个语法错误:
students.Cells(studentRow, StartColumn).Formula = _
"=If($" & SurnameColumnStr & studentRow & " <> """", if($" & colonnaStr & studentRow & _
" <> """", $" & colonnaStr & " & $" & pointRow & ", 0), """")"
我无法纠正这段代码:($" & colonnaStr & " & $" & pointRow & "
就像拥有"$B$3"
)
我尝试了几种方法都没有运气。任何帮助将非常感激。
解决方案
要"$B$3"
摆脱colonnaStr
(列引用)和pointRow
(行引用),您需要使用Range.Address
.
在你的Formula
字符串中使用它:
Range(colonnaStr & pointRow).Address(True, True, xlA1)
结果会给你$B$3
。
要了解更多信息,请阅读这里
推荐阅读
- ios - MDC 因 'NSInvalidArgumentException' 而崩溃,原因:'-[UIButton applyOutlinedThemeWithScheme:]:无法识别的选择器已发送到实例
- java - Apache Kafka Streams:如何从使用内存键值存储切换到持久键值存储?
- audio - ffmpeg图像+音频转视频,文件很大?
- powerbi - 单独运行总计度量的不同计数
- python - JSONdata使用beautifulsoup解析并输出错误
- scala - 响应式 Web 应用程序读取 twitter 流 Play Scala
- java - 如何修复未解决的参考:javafxplugin?
- flutter - BLoC:多次调用监听回调
- xquery - 如何比较两个数字(两次)并在 XQuery 中返回一个字符串
- powershell - 如何使用 powershell 从 citrix PVS 控制台释放虚拟磁盘的锁?