2014-12-26 95 views
0

我在這裏遇到問題,是否可以在RC公式中調用rowCount(行&列)?Excel VBA將值調用到公式

Dim rowCount As Long 
    Sheets("VBAResult").Select 
    Columns("A:A").Select 
    rowCount = Selection.Count 
    Columns("E:E").Select 
    Selection.SpecialCells(xlCellTypeBlanks).Select 
    Selection.FormulaR1C1 = _ 
     "=IF(ABC!R[rowCount]C[-3] <> """",ABC!R[rowCount]C[-3],"""")" 

回答

2

是的,它是可能的:

Selection.FormulaR1C1 = _ 
    "=IF(ABC!R[" & rowCount & "]C[-3] <>"""",ABC!R[" & rowCount & "]C[-3],"""")" 

順便說一句,考慮如何使用選擇How to avoid using Select in Excel VBA macros

避免