VBA Print dynamic range

Steven Cohen

New Member
Joined
Jul 6, 2016
Messages
26
Hi All

I am struggling to find code for this, I have looked through the forums but haven't found one that works for me.

All I want to do is have a print function on a report tab that varies in length depending on the results given. Columns will always be from $E2:$U - depending on the results given this can be anywhere from U20 all the way on to U1000 etc.

Column U does not always have a value in it, all columns E-T will always have a value in them to find the last row.

Any help will be greatly appreciated

Thanks
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
That will get you the last used row so you can select the full range and print out

Code:
Dim lLastRow as long

    lLastRow = Range("E" & Rows.Count).End(xlUp).row

So you can print out by

Code:
Range("[COLOR=#333333][FONT=Verdana]$E2:$U" & lLastRow).PrintOut[/FONT][/COLOR]
 
Last edited:
Upvote 0
No problem. Determining the last used row is something you'll use a lot.
 
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top