2015-07-20 79 views
0

我想填寫公式R1C1和我正在使用的代碼工作數值或字符串條目,但不會爲公式。 這是我迄今爲止如何填寫FormulaR1C1?

Dim sourceCol As Integer, rowCount As Integer 
sourceCol = 4 
rowCount = Cells(Rows.Count, sourceCol).End(xlUp).Row 
Range("K11:K" & LastRow).FormulaR1C1 = "=IF(R[0]C[-8]="""","",R[0]C[-9]&R[0]C[-6])" 

列d最後一個單元格是1000左右,我知道這個作品在其他情況下。 你能幫忙嗎?

感謝

+0

您還需要雙引號的空字符串。這工作正常''= IF(R [0] C [-8] =「」「」「」「」「,R [0] C [-9]&R [0] C [-6])」' – pathDongle

回答

0

我提供了幾個解決方案,在這裏 - 使用FillDown關鍵字或引用剛纔的整個範圍。
另外,你沒有在你的公式中加雙引號 - 他們都需要加倍。
在R1C1符號你只是用R引用相同的行不R [0]

  • RC是同一行,同一列中。
  • - [R [-1]Ç是相同的列,-1行
  • R1C2是行1,列2

    With ActiveSheet 
    
        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 
        '- To FillDown you can use. 
        '.Range("K11").FormulaR1C1 = "=IF(RC[-8]="""""""","""",RC[-9]&RC[-6])" 
        '.Range(.Cells(11, 11), .Cells(rowCount, 11)).FillDown 
        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 
    
        .Range(.Cells(11, 11), .Cells(rowCount, 11)).FormulaR1C1 = "=IF(RC[-8]="""""""","""",RC[-9]&RC[-6])" 
    End With 
    
+0

謝謝你的幫助,最後我用你的幫助來糾正我的工作表,並表明我認識到我自己的代碼有什麼問題。 – Kalaan

0

從達倫上面幫助的工作原理,但是下面也是。

Dim sourceCol As Integer, rowCount As Integer 
sourceCol = 4 
rowCount = Cells(Rows.Count, sourceCol).End(xlUp).Row 
Range("K11:K" & rowCount).FormulaR1C1 = "=IF(RC[-8]="""","""",RC[-9]&RC[-6])"