Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Hide or display worksheets based on form
Worksheet 1 displays a list of questions. Based on the answer of those
questions (via checkbox), I would like to display different worksheets. For example the worksheet one is always displayed. If you select yes to question #1, then worksheet 2 appears. If you select yes to question #2 then worksheet 3 also appears. Can this be done? |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Hide or display worksheets based on form
Yes of course it can be done, using code similar to below, it goes in the sheet1 code module: Code: -------------------- Private Sub CheckBox1_Click() Dim Sh As Worksheet For Each Sh In Sheets If Sh.Name = "Sheet1" Or Sh.Name = "Sheet2" Then Else Sh.Visible = xlSheetHidden End If End Sub Private Sub CheckBox2_Click() Dim Sh As Worksheet For Each Sh In Sheets If Sh.Name = "Sheet1" Or Sh.Name = "Sheet3" Then Else Sh.Visible = xlSheetHidden End If End Sub Private Sub CheckBox3_Click() Dim Sh As Worksheet For Each Sh In Sheets If Sh.Name = "Sheet1" Or Sh.Name = "Sheet4" Then Else Sh.Visible = xlSheetHidden End If End Sub -------------------- Shawnn;164128 Wrote: Worksheet 1 displays a list of questions. Based on the answer of those questions (via checkbox), I would like to display different worksheets. For example the worksheet one is always displayed. If you select yes to question #1, then worksheet 2 appears. If you select yes to question #2 then worksheet 3 also appears. Can this be done? -- Simon Lloyd Regards, Simon Lloyd 'The Code Cage' (http://www.thecodecage.com) ------------------------------------------------------------------------ Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1 View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=45581 |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Hide or display worksheets based on form
Hi,
Assuming you have a separate checkbox for each sheet the code for each would look something like this Private Sub CheckBox1_Click() If CheckBox1 = True Then Sheet2.Visible = xlSheetVisible Else Sheet2.Visible = xlSheetHidden End If End Sub -- If this helps, please click the Yes button Cheers, Shane Devenshire "Shawnn" wrote: Worksheet 1 displays a list of questions. Based on the answer of those questions (via checkbox), I would like to display different worksheets. For example the worksheet one is always displayed. If you select yes to question #1, then worksheet 2 appears. If you select yes to question #2 then worksheet 3 also appears. Can this be done? |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
Hide or display worksheets based on form
Hi again,
I realize I should add that in the notation Sheet2.Visible = xlSheetVisible Sheet2 is the code windows name for the sheet if you use the spreadsheet name you must write the above line as Sheets("Sheet2").Visible = xlSheetVisible -- If this helps, please click the Yes button Cheers, Shane Devenshire "Shawnn" wrote: Worksheet 1 displays a list of questions. Based on the answer of those questions (via checkbox), I would like to display different worksheets. For example the worksheet one is always displayed. If you select yes to question #1, then worksheet 2 appears. If you select yes to question #2 then worksheet 3 also appears. Can this be done? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Is there a formula to hide/ display row based on cell value in Exc | Excel Worksheet Functions | |||
how to hide a form button in a worksheet | Excel Discussion (Misc queries) | |||
Automate display/ hide rows in excel based on yes/no check box | Excel Discussion (Misc queries) | |||
Is there a way to hide worksheets and/or rows/columns based on information enter into a particular cell of range of cells? | New Users to Excel | |||
have 3 worksheets, 1 is a form, the other 2 data for the form-wan. | Excel Worksheet Functions |