ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Autofill Destination range open (https://www.excelbanter.com/excel-programming/419487-autofill-destination-range-open.html)

J.W. Aldridge

Autofill Destination range open
 
recorded this line in a macro....

Need for this to read as an open range instead of stopping at F784.
Will always start at A2- F2 but last row (F784) may change..


Selection.AutoFill Destination:=Range("A2:F784")

Michael

Autofill Destination range open
 
To find the last row based on F

iLastRow=Range("F65536").end(xlup).row
Then you substitute in your instruction:
Selection.AutoFill Destination:=Range("A2:F" & iLastRow)
--
If this posting was helpful, please click on the Yes button.
Regards,

Michael Arch.




"J.W. Aldridge" wrote:

recorded this line in a macro....

Need for this to read as an open range instead of stopping at F784.
Will always start at A2- F2 but last row (F784) may change..


Selection.AutoFill Destination:=Range("A2:F784")


mudraker[_404_]

Autofill Destination range open
 

The suggestion in the previous reply is not fool proof in all versions
of Excel 5 & later

And it assumes column A has an entry in the last used row
try replacing
iLastRow=Range("F65536").end(xlup).row

with this code which finds last used row on sheet

lLR=Cells.Find(what:="*", SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
range("a2:f2").AutoFill Destination:=Range("A2:F" & lLR)


--
mudraker
------------------------------------------------------------------------
mudraker's Profile: http://www.thecodecage.com/forumz/member.php?userid=18
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=24702



All times are GMT +1. The time now is 03:39 PM.

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