[英]How to input a formula into an empty cell if another cell is not empty in excel
我搜索了stackoverflow,發現了一些與我的非常相似的主題,但是答案不是特定的,通常只是vba代碼,沒有任何解釋。 以下是我正在嘗試做的事情。 1.如果填充了一個空單元格(比如說C3)2.然后將公式輸入到AT3的另一個空單元格中3. = VLOOKUP(C3,'WC Chart'!A3:G351,3,FALSE)這是我的vlookup公式,它作品。 我只需要它在c3填充文本時才在空單元格中填充,所以我需要一種vba的方式來做到這一點。
像這樣...
'This line will place the formula in AT3 only if C3 is not blank
If Range("C3").Value <> "" Then Range("AT3").Formula = "=VLOOKUP(C3,'WC Chart'!A3:G351,3,FALSE)"
'This line will place the formula in AT3 and if C3 is blank, formula will return a blank in AT3
'And if C3 is not blank, the VLookUp formula will return an output
Range("AT3").Formula = "=IF(C3="""","""",VLOOKUP(C3,'WC Chart'!A3:G351,3,FALSE))"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.