![]() |
Stopping Autofill at alst line of file
I use the code below to autofill columns,(using formulas), which is done successfully except that it creates garbage past the last line of the file. Range("V2:AF2").AutoFill Destination:=Range("V2", Range("AF2").End(xlDown)(0)) How can I stop it doing this to row 65536? Thanks -- leskoby ------------------------------------------------------------------------ leskoby's Profile: http://www.excelforum.com/member.php...o&userid=26616 View this thread: http://www.excelforum.com/showthread...hreadid=399956 |
Stopping Autofill at alst line of file
leskoby There are several ways to do this. Here is one way This finds last row with data in it then autofills down to that row Dim GetBottomRow As Long GetBottomRow = Cells.Find(what:="*", SearchOrder:=xlByRows, _ SearchDirection:=xlPrevious).Row Range("v2:af2").AutoFill Destination:= _ Range("v2:af" & GetBottomRow), Type:=xlFillDefault -- mudraker ------------------------------------------------------------------------ mudraker's Profile: http://www.excelforum.com/member.php...fo&userid=2473 View this thread: http://www.excelforum.com/showthread...hreadid=399956 |
Stopping Autofill at alst line of file
Thanks Mudraker, worked like a charm. -- leskoby ------------------------------------------------------------------------ leskoby's Profile: http://www.excelforum.com/member.php...o&userid=26616 View this thread: http://www.excelforum.com/showthread...hreadid=399956 |
All times are GMT +1. The time now is 02:46 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com