locked
Problem with entering absolute reference while entering in to individually in to multiple rows RRS feed

  • Question

  • I want to add the absolute reference to the right value of "=RC[-1]-RC[-1]". I want to do this for 73 individual rows and I want the absolute reference to add that specific cell value(e.g.D20-$D$20) not like (D10-$D$1). I have recorded the macro for the have formula RC[-1]-RC[-1] and absolute reference added to the same .But didn't work out  for rest rows as it starts pasting same absolute reference for all. So, if anyone can help me solve this problem than it would be great. Thanks

    Sub Macro10()
    '
    ' Macro10 Macro
    '

    '
        ActiveCell.FormulaR1C1 = "=RC[-1]-RC[-1]"
        Range("E1").Select
        Selection.AutoFill Destination:=Range("E1:E72"), Type:=xlFillDefault
        Range("E1:E72").Select
        Range("E1").Select
        ActiveCell.FormulaR1C1 = "=RC[-1]-R1C4"

        Range("E2").Select
    End Sub


    Wednesday, May 11, 2016 9:25 AM

Answers

  • You need to loop through your selection, something like this:

     

    Dim myRange as Range

    Set myRange = range("E1:E72").select

    For Each rCell In myRange.Cells rCell.formulaR1C1= "=RC[-1]-R1C4" Next rCell



    Wednesday, May 11, 2016 10:25 AM