Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print Dialog Box Code for Excel

Status
Not open for further replies.

Jamie2002

Technical User
Sep 17, 2001
62
GB
I've made a dialog box on which I'm going to put a list of sheet names and check boxes by each one, the idea being users can pick which sheets they want to print and then a print button which will put all the sheets they want into an array and print them in one go.

I'm having problems referring to the check box in VBA and how to put certain sheet names into an array from which to then print.

As you will see below I haven;t got very far and am not very good at this. Any help will be appreciated.

Sub PrintRange()

Dim S As String
DialogSheets("Print Menu").Select
If object.("Check Box 6") = Enabled = Empty Then
S = "Summary"
Else
End If
End Sub

Thanks
 
What version of Excel are you running? User defined dialog boxes are a thing of the past. You want to be using UserForms if you are running Excel 95 or greater (if my memory serves me correctly)

The syntax for determining is a checkbox is checked is
Code:
    Dim sSheet As String
    Dim SheetSelNbr As Integer
    DimSheetList() As String
    SheetSelNbr = 0
    For Each Control In UserForm1.Frame1.Controls
        sSheet = ""
        With Control
            If .Value Then
                SheetSelNbr = sheetcelnbr + 1
                ReDim Preserve SheetList(1 To SheetSelNbr)
                SheetList(SheetSelNbr) = .Tag
            End If
        End With
    Next
I am assuming that all the checkboxes are inside a Frame (group box).
Also, assign the corresponding sheet name to the Tag property of the check box.

Put this code in the CommandButton_Click event.
Hope this helps :) Skip,
metzgsk@voughtaircraft.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top