![]() |
Macro to set print range
If my data starts in cell B5 but the number of columns and/or rows can vary, how do I write a print macro to cover that if there are no gaps in the data i.e. one solid range of data? And how do I get around the problem of a blank line within the range? -- Brisbane Rob ------------------------------------------------------------------------ Brisbane Rob's Profile: http://www.excelforum.com/member.php...o&userid=25096 View this thread: http://www.excelforum.com/showthread...hreadid=401725 |
I'd approach it this way - find the last row from bottom and last column from the right dim prange as range endrow = cells(65536,2).end(xlup).row 'assumes there is always something in column b endcol = cells(2,256).end(xltoleft).column ' assumes there is alway something in row 2 prange = range (cells(5,2) , cells(endrow,endcol)) -- duane ------------------------------------------------------------------------ duane's Profile: http://www.excelforum.com/member.php...o&userid=11624 View this thread: http://www.excelforum.com/showthread...hreadid=401725 |
That seems to work fine. Many thanks - much appreciated. -- Brisbane Rob ------------------------------------------------------------------------ Brisbane Rob's Profile: http://www.excelforum.com/member.php...o&userid=25096 View this thread: http://www.excelforum.com/showthread...hreadid=401725 |
All times are GMT +1. The time now is 01:39 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com