[英]Return .cells range in Excel formula
我正在嘗試獲取一個腳本來找到合適的列並創建一個公式,其中包含“name”單元格。 這是腳本:
'Search for value
Dim i As Integer
i = 4
Do Until Cells(9, i).Value = ddLeveranciers.Value Or Cells(9, i).Value = ""
i = i + 1
Loop
'Add formulas
Range("D5").Formula = "=IF(" & Cells(15, i) & "<>"""",D4*" & Cells(15, i) & ","""")"
現在返回公式"=IF(1.23<>"",D4*1.23,"")"
, 1.23
是cells(15,i)
。 我希望腳本返回(例如) "=IF(D15<>"",D4*D15,"")"
。 我怎么做?
您可以使用.Address
屬性。
Range("D5").Formula = "=IF(" & Cells(15, i).Address & "<>"""",D4*" & Cells(15, i).Address & ","""")"
例如:
MsgBox(Cells(1,1).Address)
將返還$A$1
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.