Print usage range VBA

Panoos64

Well-known Member
Joined
Mar 1, 2014
Messages
890
All hi, i would like to prepare a VBA code so that, to set print area, the usage rows and columns only. Please note that the range change each time when i download the file from accounting system.
Many thanks in advance
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Code:
Sub AAAAA()
ActiveSheet.PageSetup.PrintArea = ActiveSheet.UsedRange.Address
ActiveSheet.PrintPreview
End Sub
Is this what you have in mind?
 
Upvote 0
Thank you Joliv, it works but it include range in which i deleted rows. Is it possible to change the code so that to print just rows and columns which contains data? If this help you, i would like to print till last row which contains description in col."A" Grand Total. Thanks once again for your support. Hv a great day
 
Upvote 0
After deleting rows you should save the workbook and then it should work.
Anyway, try the following.
Code:
Sub Maybe()
Dim lc As Long, GT As Long
lc = Cells.Find("*", , , , xlByColumns, xlPrevious).Column
GT = Columns(1).Find("Grand Total", , , 1).Row
    ActiveSheet.PageSetup.PrintArea = Range("A1:A" & GT).Resize(, lc).Address
ActiveSheet.PrintPreview
End Sub
 
Upvote 0
Thank you so much joliv. It works perfect now. Thanks once again for your support and your time which you spent for my project. Hv a great lovely day!
 
Upvote 0
Thank you for letting us know that it all works to your satisfaction.
Good luck
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,323
Members
452,635
Latest member
laura12345

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