Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

autofill not working

Status
Not open for further replies.

peach255

Programmer
Jan 20, 2003
29
US
I have an autofill VBA code to fill the cells from a formula. When I run the procedure, it did not autofill. However, when I step through the code, it did autofill each cells. I am not sure why it does not work when I run the procedure, but works when I step through the code one by one. Here is my code:

GAPDHNFormula = "=IF(RC[-14]>0.9,RC[-4]/RC[-14],RC[-4])"

wbOne.Worksheets(1).Range("AC10").Formula = GAPDHNFormula
Range("AC10").autofill Destination:=Range("AC10:AC88"), Type:=xlFillDefault

wbOne is referring to the 1st workbook I have open, which I assigned the workbooks to object variables. Thank you!
 
Try this, I don't know if it will help or not, but it's worth a try:
Code:
GAPDHNFormula = "=IF(RC[-14]>0.9,RC[-4]/RC[-14],RC[-4])"
wbOne.Activate
Worksheets(1).Range("AC10").Select
Selection.FormulaR1C1 = GAPDHNFormula
Selection.AutoFill Destination:=Range("AC10:AC88"), Type:=xlFillDefault
I think the problem may lie with using .Formula rather than .FormulaR1C1 but try the above code anyway. It'll help to breakdown the problem and work out what's actually happening.

Clive [infinity]
Ex nihilo, nihil fit (Out of nothing, nothing comes)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top