ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Program an autofill (https://www.excelbanter.com/excel-programming/294727-program-autofill.html)

Pete K

Program an autofill
 
I want to program an autofill to the end of the rows in a column, but
it won't be the same number of rows each time. When I double click on
the cell tail (small box in lower right corner of highlite cell box)
it fills to the end but in the program it records it to a certain row.
I need it to go to the bottom each time but that bottom will vary
each time.

I figured one way to do it is to have excel count the number of rows,
store it in a variable and fill to that row but I wanted an easier
way. Any suggestions?

Thank you in advance,
Pete K

Tom Ogilvy

Program an autofill
 
There are many ways, but they all requiring finding the last filled row (you
have done that already and it appears you find that too cumbersome)

assume the fill is going to be in column D

Dim rng as Range
' get the range from column C
set rng = Range(cells(1,3),cells(1,3).End(xldown))
' go over one column
set rng = rng.offset(0,1)

now rng is the range you want to fill.

--
Regards,
Tom Ogilvy

"Pete K" wrote in message
om...
I want to program an autofill to the end of the rows in a column, but
it won't be the same number of rows each time. When I double click on
the cell tail (small box in lower right corner of highlite cell box)
it fills to the end but in the program it records it to a certain row.
I need it to go to the bottom each time but that bottom will vary
each time.

I figured one way to do it is to have excel count the number of rows,
store it in a variable and fill to that row but I wanted an easier
way. Any suggestions?

Thank you in advance,
Pete K




Peter Kraniak

Program an autofill
 
Thank you very much.



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


All times are GMT +1. The time now is 06:37 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com