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

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
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

Forum statistics

Threads
1,223,723
Messages
6,174,123
Members
452,546
Latest member
Rafafa

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