Consulting

Results 1 to 3 of 3

Thread: Solved: ActiveCell.FormulaR1C1 dynamic column

  1. #1
    VBAX Regular
    Joined
    Apr 2010
    Posts
    39
    Location

    Unhappy Solved: ActiveCell.FormulaR1C1 dynamic column

    Hi, all. I need to use a loop to run through the necessary column, and if match the condition, then autofill the column's data to desired column. but when the macro run to ActiveCell.FormulaR1C1 = "=RC[-123+i]" , it got error msg says : run time error"1004" Application-defined or object-defined error? how should i modify this problem?? Please help. Thank you!
    i = 28
            Do While i <= 41
             If range("GP3").Value = Cells(4, i).Value Then
              If range("GP4").Value = Cells(5, i).Value Then
                range("GP8").Select
                ActiveCell.FormulaR1C1 = "=RC[-123+i]"
                selection.AutoFill Destination:=range(Cells(8, "GP"), Cells(GrandTotalRowCount, "GP")), Type:=xlFillDefault
              End If
             End If
             i = i + 1
            Loop

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Try

    "=RC[" & -123 + i & "]"
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    Apr 2010
    Posts
    39
    Location
    THANK YOU XLD. CAN WORK NOW.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •