Page 1
Page 1
Started By
Message

VBA code to Select multiple sheets and print

Posted on 4/6/20 at 11:09 am
Posted by VermilionTiger
Member since Dec 2012
39156 posts
Posted on 4/6/20 at 11:09 am
I'm looking to have a print button that brings up a listbox, which will then have selections that determine which sheets need to be selected. After selected, I want print PDF them all as 1 book.

Every time I think I figure out a solution, it only selects 1 sheet, rather than all of them.

Lets just call it the following
Sheet13
Sheet14
Sheet15
Sheet16

What I tried was:

quote:

Private Sub cbPrintBook_Click

Sheet13.Select
Sheet14.Select
Sheet15.Select
Sheet16.Select

ActiveWindow.SelectSheets.printout

End Sub


FYI, I am only trying to figure out the initial code. Once I get that, I'll work it into my listbox variables.
This post was edited on 4/6/20 at 11:10 am
Posted by VermilionTiger
Member since Dec 2012
39156 posts
Posted on 4/6/20 at 11:19 am to
Ended up doing it by doing the tried and true method of VBA.. recording a macro and stealing the code

Private Sub cbPrintBook_Click()

Sheets(Array("Sheet13", "Sheet14")).Select
Sheets("Sheet13").Activate
ActiveWindow.SelectedSheets.PrintOut

End Sub
Posted by mdomingue
Lafayette, LA
Member since Nov 2010
45803 posts
Posted on 4/6/20 at 7:43 pm to
quote:


Ended up doing it by doing the tried and true method of VBA.. recording a macro and stealing the code


My go to.
first pageprev pagePage 1 of 1Next pagelast page
refresh

Back to top
logoFollow TigerDroppings for LSU Football News
Follow us on X, Facebook and Instagram to get the latest updates on LSU Football and Recruiting.

FacebookXInstagram