AutoFill Across Columns

RunTime91

Active Member
Joined
Aug 30, 2012
Messages
276
Office Version
  1. 365
Hard to believe I am here for this, but.... here I am

Just trying to AutoFill xlFillSeries from Column A to LastColumn

Here is where I'm at (I think I'm close?)
Code:
Application.ScreenUpdating = False
  
    With Sheet1
      Lc = .Cells(1, .Columns.Count).End(xlToLeft).Column
        .Rows("1:1").Insert
          .Range("A1") = 1
        .Cells(1, Lc).AutoFill , xlFillSeries
      .Range("A1").Select
    End With
  
  Application.ScreenUpdating = True

What I'm trying to accomplish is to simply put numbers across the tops of my column names...(changing the sheet to R1C1 wont' work for this project.)

And, as I'm sure most of you reading this will know - I'm getting an AutoFill Method of Range Error

Help?

Thanks everyone...
 
Wow ~ This thread has turned into quite the tutorial for how to fill accross columns.

Joe & Peter ~

Your expertise, insights and explanations will/(should) keep this thread being viewed for years to come.

Especially by folks whom, like myself, come here looking not for just a solution, but for a better understanding of how and why that solution works.

Sites like this work only because of experts like yourselves and I for one can't thank you enough for sharing your expertise with 'rooks' like myself.

(some years ago I made a MsgBox pop-up that said 'Hello World!' and now everybody thinks I'm an Excel Guru) lol.

Joe & Peter ~ Thank You (and the rest of this community) again - Very Much for helping me to keep them believing that!

RT91
 
Upvote 0

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
.. and just for the record here is a way without needing to put anything in any of the cells first. (Though I'm not particularly recommending this as a 'better way')
Code:
.Range("A1").Resize(, lc).Value = Application.Transpose(Evaluate("row(1:" & lc & ")"))
Just to follow up on this method, if you know that the last column will never be more than some fixed value (say, 700 columns), you can use this simple code line letting the actual lc inside the Resize property call control the final output...

.Range("A1").Resize(, lc) = [COLUMN(A:ZZ)]

I used Column ZZ (which is the 702nd column) because I think ZZ looks "nicer" in the formula than ZX (which is 700th column). Anyway, the idea is to set the last column to a column letter designation which is always going to be greater than the largest column you will ever need to fill in.
 
Upvote 0

Forum statistics

Threads
1,214,782
Messages
6,121,532
Members
449,037
Latest member
tmmotairi

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