Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 683
Default Check Box Question

I have a user form with several Check Boxes that are for controlling
worksheets in a workbook.

Each check box is for hiding or unhiding the different worksheets in a
workbook from the user form2.

Workbook name = Installer Forms
Worksheet name = Sheet 1
Checkbox names = Office_Package_Preparations_101

I want when the Box is checked for the worksheet to be shown and when the
box is not checked for the worksheet to be hidden.






  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Check Box Question

Hi Brian,

Important consideration is that you cannot hide all sheets so must test for
at least 2 visible sheets before hiding a sheet. If only one sheet visible
then unchecking the last checkbox is ignored and it is re-checked. All of
your CheckBox code should be like the following.

You could if you wish place the main code in a standard module and call it
from the CheckBox click events and pass the worksheet name to the code.

Private Sub ChkSht1_Click()

Dim ws As Worksheet
Dim i As Long

'Edit ChkSht1 to your CheckBox Name
If Me.ChkSht1 = True Then
'Edit "Sheet1" to your sheet name
Sheets("Sheet1").Visible = True
Else
'Cannot hide all sheets so at least
'2 must be visible before hiding one.
For Each ws In Worksheets
If ws.Visible Then
i = i + 1
If i 1 Then Exit For
End If
Next ws

If i 1 Then
Sheets("Sheet1").Visible = False
Else
'Set back to True (Visible)
Me.ChkSht1 = True
End If
End If
End Sub

--
Regards,

OssieMac


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Check box question??? Pas Excel Discussion (Misc queries) 4 March 9th 10 05:41 PM
Check Box Question Ksean Excel Worksheet Functions 5 January 8th 10 02:25 AM
check box question mac Excel Worksheet Functions 3 September 1st 09 12:20 AM
Check Box Question John Bundy Excel Programming 1 December 28th 06 11:51 AM
Check Box Question Andrew Taylor Excel Programming 0 December 28th 06 10:39 AM


All times are GMT +1. The time now is 08:12 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"