[英]Excel VBA .Formula - syntax error adding absolute reference to cell
我在這個 VBA 代碼中有語法錯誤:
students.Cells(studentRow, StartColumn).Formula = _
"=If($" & SurnameColumnStr & studentRow & " <> """", if($" & colonnaStr & studentRow & _
" <> """", $" & colonnaStr & " & $" & pointRow & ", 0), """")"
我不能把這段代碼寫對: $" & colonnaStr & " & $" & pointRow & "
(就像有"$B$3"
)
我嘗試了幾種方法都沒有運氣。 任何幫助將非常感激。
要從colonnaStr
(列引用)和pointRow
(行引用)中獲取"$B$3"
,您需要使用Range.Address
。
在您的Formula
字符串中使用它:
Range(colonnaStr & pointRow).Address(True, True, xlA1)
結果會給你$B$3
。
要了解更多信息,請閱讀這里
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.