Macro to set print range

B

Brisbane Rob

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?
 
D

duane

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))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top