PDA

View Full Version : Solved: ActiveCell.FormulaR1C1 dynamic column



Yjmmay34
07-18-2010, 11:24 PM
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

Bob Phillips
07-19-2010, 12:31 AM
Try

"=RC[" & -123 + i & "]"

Yjmmay34
07-19-2010, 06:56 PM
THANK YOU XLD. CAN WORK NOW.