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

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
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,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