Results 1 to 9 of 9

Clearing form control checkboxes automatically on opening workbook

Threaded View

  1. #1
    Registered User
    Join Date
    02-12-2009
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2007
    Posts
    32

    Clearing form control checkboxes automatically on opening workbook

    Hi to all,

    I'm developing a workbook containing 121 sheets. Sheet 1 is effectively an index, and uses 120 form control checkboxes to unhide and display the selected sheets individually.

    The code I'm using for each checkbox is below and is in a module.

    Sub CheckBox1_Click()
    Dim s As String, cbx As CheckBox
    s = Application.Caller
    Set cbx = ActiveSheet.CheckBoxes(s)
        If cbx.Value = xlOn Then
            Sheet2.Visible = xlSheetVisible
            Sheet2.Select
        Else
            Sheet2.Visible = xlSheetHidden
        End If
    End Sub
    The code will hide the sheet again if the box is unchecked, and this is what should be done by the operator before closing the workbook. Surprise - that doesn't always happen.

    I've worked out that adding the following code (for each sheet) to the workbook module does the job of hiding the sheets on opening.

    Private Sub Workbook_Open()
        Sheet2.Visible = xlSheetHidden
    End Sub
    I'm left with two problems and any help will be greatly appreciated.

    Code to hide all the sheets on opening the workbook (except sheet 1), rather than repeating the line above 120 times?

    Code to uncheck (on opening the workbook) any checkboxes which had not been unchecked when the worbook was last saved/closed? My preference is to do this automatically rather than with a macro requiring some user input.

    I'm very new to vba (still at the guess-copy-try stage) so apologies if the questions have simple or obvious answers.

    Thanks in advance.

    Cheers.
    Last edited by glenin; 05-08-2009 at 08:20 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1