VBA Code to Print Only Visible Cells

jasho

New Member
Joined
Jun 20, 2012
Messages
9
I have a simple Macro that can print in both Landscape & Potrait but has to use custom views to print. My spreadsheet has Subtotals in it and I'd like to print without the subtotals expanding which is currently happening. Can Anyone Assist? See my simple Macro below. Please Help.

Sub CommandButton1_Click()
ActiveWorkbook.CustomViews("custom print 1").Show
ActiveWorkbook.PrintOut
ActiveWorkbook.CustomViews("custom print 2").Show
ActiveWorkbook.PrintOut
MsgBox "Priting Complete"
End Sub

Thanks.
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Hi General Ledger,

Thank you for the response.
I tried to run it with that code and when I tried to print, it just printed them all. I'm fairly new tO VBA and was wondering if I'm doing it correctly? (see my vba code below)

Sub CommandButton1_Click()
ActiveWorkbook.CustomViews("custom print 1").Show
ActiveWorkbook.PrintOut
ActiveSheet.Outline.ShowLevels RowLevels:=3

ActiveWorkbook.CustomViews("custom print 2").Show
ActiveWorkbook.PrintOut
ActiveSheet.Outline.ShowLevels RowLevels:=3
MsgBox "Priting Complete"
End Sub

Thanks,

Jasho
 
Upvote 0

Forum statistics

Threads
1,213,515
Messages
6,114,080
Members
448,548
Latest member
harryls

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