AutoFill method of Range class failed

Ossian13

New Member
Joined
Oct 21, 2016
Messages
46
Hi everyone,

im trying to Autofill rows within a column with a formula and im using this :

Code:
 Range("G2").Select    ActiveCell.FormulaR1C1 = "=LEFT(H2,10)"
    Columns("G:G").Select

Range("G2").Select
    Selection.AutoFill Destination:=Range("G" & Rows.Count).End(xlUp)
And i get the error from the title. Could someone tell me what i wrote wrong here? Or what have i missed?

Thank you,
Ossian
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
i found the solution, i will paste here if someone might need it also.
Code:
Range("G2").Select
    If Lastrow > 2 Then
    Range("G2").AutoFill Destination:=Range("G2:G" & Lastrow)
    End If
This piece of if made the thing work. I found it also here on forum but in older posts.

Cheers,
Ossian.
 
Upvote 0
FYI
you could also use
Code:
Range("G2:G" & LastRow).Formula = "=Left(H2,10)"
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,306
Members
452,633
Latest member
DougMo

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