Select Multiple Sheets from Menu

G

Guest

I have multiple worksheets in my workbook. I have a pop-up form with
mulitple checkboxes. I want to use this menu to to select specific sheets so
I can print them as a package. The control source for all checkboxes are in
"data entry" worksheet. Does someone have simple code to achieve this?
Obviously I am a fairly new user so any help would be appreciated.

Example Sheets --> "Data Entry", "Title Page", "Analysis", "Chart 1",
"Chart 2" etc.
 
S

Susan

capp -
yes, you can do this.

go ahead & set up all the checkboxes - just keep the auto-created
names Checkbox1, Checkbox2, etc.

in your userform initialization sub, you can loop thru the checkboxes
and change the caption (what shows to the user) to the sheet names.

dim oControl as control

for each oControl in controls
if typeof oControl is msforms.checkbox then
ocontrol.caption = worksheets(1).name
end if
next oControl

hmmmmmmmm..... i'm a little lost myself. :) (relative newbie myself
6 mos or so) the above loop won't work because it will name ALL the
checkboxes the name of sheet1.
i can't see how you'd loop thru BOTH the checkboxes and the sheets;
i'm sure you can do it, but i'm on a dial-up computer here & can't
easily search the newsgroup while i'm writing this. i don't know if
you can have a "for-each" loop inside a "for-each" loop. :/

ok, alternatively, you could also do them individually....... (this
is also in the initialization sub)

checkbox1.caption = worksheets(1).name
checkbox2.caption = worksheets(2).name
checkbox3.caption = worksheets(3).name
etc.

you might need to change these to me.checkbox1 blah blah blah.
hope this helps!
if not, search the newsgroup for the problems & you'll come up with
lots of examples.
susan
 
G

Guest

THanks everyone! Got it done!

Troubled User said:
I made a similiar request / post several days ago and got help to create the
following.

This code will create a string of multiple different sheets and send to the
printer at once. I requires that you have named the sheets in VB. There
are lots of ways to do this, but I was trying to load an array so that it
could be ONE print job for multiple sheets.

Dim myStr As String
Dim PrintArray As Variant

'Set to string to blank
myStr = ""

'Check the individual values for true (mine are called NarativeCheckBox
and ExecutiveSummaryCheckbox below:

If Me.NarrativeCheckBox = True Then
myStr = myStr & "," & ShtNarrative.Name
End If

If Me.ExecutiveSummaryCheckBox = True Then
myStr = myStr & "," & ShtExecutiveSummary.Name
End If

If myStr = "" Then
MsgBox "nothing checked"
Exit Sub
End If

myStr = Mid(myStr, 2)

PrintArray = Split(myStr, ",")

Sheets(PrintArray).Select

ActiveWindow.SelectedSheets.PrintOut
 
G

Guest

I made a similiar request / post several days ago and got help to create the
following.

This code will create a string of multiple different sheets and send to the
printer at once. I requires that you have named the sheets in VB. There
are lots of ways to do this, but I was trying to load an array so that it
could be ONE print job for multiple sheets.

Dim myStr As String
Dim PrintArray As Variant

'Set to string to blank
myStr = ""

'Check the individual values for true (mine are called NarativeCheckBox
and ExecutiveSummaryCheckbox below:

If Me.NarrativeCheckBox = True Then
myStr = myStr & "," & ShtNarrative.Name
End If

If Me.ExecutiveSummaryCheckBox = True Then
myStr = myStr & "," & ShtExecutiveSummary.Name
End If

If myStr = "" Then
MsgBox "nothing checked"
Exit Sub
End If

myStr = Mid(myStr, 2)

PrintArray = Split(myStr, ",")

Sheets(PrintArray).Select

ActiveWindow.SelectedSheets.PrintOut
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top