簡體   English   中英

在Excel公式中返回.cells范圍

[英]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.23cells(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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM