Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Hiding worksheets based on user selection
Hello,
I have created an Excell spreadsheet with 5 sheets. The tabs are called: Introduction (sheet 1), Process A(sheet 2), Process B(sheet3), Process C(sheet 4), & Process D (sheet 5). For the Introduction sheet, I have four questions that can be answered Yes or No. By the way, I am using a drop-down menu for the Yes/No response. How can I hide specific sheets if the user answers yes to a question? For example: If the user answer yes to the first question, then I would like to hide sheets 3-5? Thanks. |
#2
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Hiding worksheets based on user selection
This requires programming. No formula can do this.
It is not too difficult. -Press Alt+F11 to open the VBA window -If you don't see a file tree on the left press Ctrl+R -Double click on the sheet where your drop down menus are -Place the copy and paste the following code into the window: Private Sub Worksheet_Change(ByVal Target As Range) If Range("B2").value = "Yes" then Sheets("Process B").visible = false Sheets("Process C").visible = false Sheets("Process D").visible = false ElseIf Range("B2").value = "No" then Sheets("Process B").visible = true Sheets("Process C").visible = true Sheets("Process D").visible = true End if End Sub Note that I've assumed that your drop down for the first question is in cell B2. You can change that easy enough. I've also assumed that you've named your sheets Process B, etc. If you need to change them make sure you keep the name inside quotation marks. Without more information it's hard to get this perfect for your needs, but hopefully it gets you started. -- JNW "HL" wrote: Hello, I have created an Excell spreadsheet with 5 sheets. The tabs are called: Introduction (sheet 1), Process A(sheet 2), Process B(sheet3), Process C(sheet 4), & Process D (sheet 5). For the Introduction sheet, I have four questions that can be answered Yes or No. By the way, I am using a drop-down menu for the Yes/No response. How can I hide specific sheets if the user answers yes to a question? For example: If the user answer yes to the first question, then I would like to hide sheets 3-5? Thanks. |
#3
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Hiding worksheets based on user selection
JW, Thanks for the code. I was able to get it to work. I do have another
questinon. If the user changes his/her answer (example, answer was yes, now the cell is blank) how do you get the worksheets to be visible again. "JNW" wrote: This requires programming. No formula can do this. It is not too difficult. -Press Alt+F11 to open the VBA window -If you don't see a file tree on the left press Ctrl+R -Double click on the sheet where your drop down menus are -Place the copy and paste the following code into the window: Private Sub Worksheet_Change(ByVal Target As Range) If Range("B2").value = "Yes" then Sheets("Process B").visible = false Sheets("Process C").visible = false Sheets("Process D").visible = false ElseIf Range("B2").value = "No" then Sheets("Process B").visible = true Sheets("Process C").visible = true Sheets("Process D").visible = true End if End Sub Note that I've assumed that your drop down for the first question is in cell B2. You can change that easy enough. I've also assumed that you've named your sheets Process B, etc. If you need to change them make sure you keep the name inside quotation marks. Without more information it's hard to get this perfect for your needs, but hopefully it gets you started. -- JNW "HL" wrote: Hello, I have created an Excell spreadsheet with 5 sheets. The tabs are called: Introduction (sheet 1), Process A(sheet 2), Process B(sheet3), Process C(sheet 4), & Process D (sheet 5). For the Introduction sheet, I have four questions that can be answered Yes or No. By the way, I am using a drop-down menu for the Yes/No response. How can I hide specific sheets if the user answers yes to a question? For example: If the user answer yes to the first question, then I would like to hide sheets 3-5? Thanks. |
#4
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Hiding worksheets based on user selection
Replace this line:
ElseIf Range("B2").value = "No" then With: Else: That will say that if B2 is changed to anything other other than "yes" it will make the sheets available again. -- JNW "HL" wrote: JW, Thanks for the code. I was able to get it to work. I do have another questinon. If the user changes his/her answer (example, answer was yes, now the cell is blank) how do you get the worksheets to be visible again. "JNW" wrote: This requires programming. No formula can do this. It is not too difficult. -Press Alt+F11 to open the VBA window -If you don't see a file tree on the left press Ctrl+R -Double click on the sheet where your drop down menus are -Place the copy and paste the following code into the window: Private Sub Worksheet_Change(ByVal Target As Range) If Range("B2").value = "Yes" then Sheets("Process B").visible = false Sheets("Process C").visible = false Sheets("Process D").visible = false ElseIf Range("B2").value = "No" then Sheets("Process B").visible = true Sheets("Process C").visible = true Sheets("Process D").visible = true End if End Sub Note that I've assumed that your drop down for the first question is in cell B2. You can change that easy enough. I've also assumed that you've named your sheets Process B, etc. If you need to change them make sure you keep the name inside quotation marks. Without more information it's hard to get this perfect for your needs, but hopefully it gets you started. -- JNW "HL" wrote: Hello, I have created an Excell spreadsheet with 5 sheets. The tabs are called: Introduction (sheet 1), Process A(sheet 2), Process B(sheet3), Process C(sheet 4), & Process D (sheet 5). For the Introduction sheet, I have four questions that can be answered Yes or No. By the way, I am using a drop-down menu for the Yes/No response. How can I hide specific sheets if the user answers yes to a question? For example: If the user answer yes to the first question, then I would like to hide sheets 3-5? Thanks. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
macro that brings user to cell based on "yes/no" response | Excel Discussion (Misc queries) | |||
Hiding columns based on user/password | Excel Worksheet Functions | |||
Hiding Worksheets | Setting up and Configuration of Excel | |||
limit cell list selection based on the selection of another list | Excel Worksheet Functions | |||
Hiding rows based on date | Excel Worksheet Functions |