Macro to set print range

  • Thread starter Thread starter Brisbane Rob
  • Start date Start date
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?
 
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))
 
Back
Top