Autofill Formula problems

chefdt

Board Regular
Joined
Jul 1, 2008
Messages
163
My code errors at the AUTOFILL method line. Do I have a syntax error somewhere.

Code:
'Continued Formatting CB IMPACT
    lastRow = sht.Range("A" & sht.Rows.Count).End(xlUp).Row
    sht.Range("V3").Select
    ActiveCell.FormulaR1C1 = "new cb"
    sht.Range("W3").Select
    ActiveCell.FormulaR1C1 = "cb impact"
    sht.Range("V4").Select
    ActiveCell.FormulaR1C1 = "=RC[-1]-RC[-5]"
    sht.Range("G1").Select
    ActiveCell.FormulaR1C1 = "=SUMIF(C[16],"">0"")"
    sht.Range("G2").Select
    ActiveCell.FormulaR1C1 = "=R[-1]C*0.25"
    sht.Range("W4").Select
    ActiveCell.FormulaR1C1 = "=(RC[-1]-(RC[-11]-RC[-12]))*RC[-21]"
    sht.Range("V4").Select
[B]    sht.Range("V4").AutoFill Destination:=sht.Range("V4:V" & lastRow), Type:=xlFillDefault[/B]
    sht.Range("W4").Select
    sht.Range("W4").AutoFill Destination:=sht.Range("W4:W" & lastRow), Type:=xlFillDefault
    sht.Columns("V:W").Select
    Selection.EntireColumn.Hidden = True
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Check your value of "lastRow". If it is 4, it won't work.
 
Upvote 0
My code errors at the AUTOFILL method line. Do I have a syntax error somewhere.

Code:
'Continued Formatting CB IMPACT
    lastRow = sht.Range("A" & sht.Rows.Count).End(xlUp).Row
    sht.Range("V3").Select
    ActiveCell.FormulaR1C1 = "new cb"
    sht.Range("W3").Select
    ActiveCell.FormulaR1C1 = "cb impact"
    sht.Range("V4").Select
    ActiveCell.FormulaR1C1 = "=RC[-1]-RC[-5]"
    sht.Range("G1").Select
    ActiveCell.FormulaR1C1 = "=SUMIF(C[16],"">0"")"
    sht.Range("G2").Select
    ActiveCell.FormulaR1C1 = "=R[-1]C*0.25"
    sht.Range("W4").Select
    ActiveCell.FormulaR1C1 = "=(RC[-1]-(RC[-11]-RC[-12]))*RC[-21]"
    sht.Range("V4").Select
[B]    sht.Range("V4").AutoFill Destination:=sht.Range("V4:V" & lastRow), Type:=xlFillDefault[/B]
    sht.Range("W4").Select
    sht.Range("W4").AutoFill Destination:=sht.Range("W4:W" & lastRow), Type:=xlFillDefault
    sht.Columns("V:W").Select
    Selection.EntireColumn.Hidden = True

Amazing...Sometimes all it takes is a second pair of eyes. Thanks!
 
Upvote 0

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top