question on creating a menu tab

pyclen

Board Regular
Joined
Jan 17, 2022
Messages
85
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
I found a solution to hide tabs that I don't need to show, the downside is all other tabs get hidden however I want a summary tab to show AND the tab (or tabs) selected.

I have to say I have no clue about VBA therefore I may not completely know how to do things, i.e., I would appreciate detailed guidance if possible.
I am not sure if this XL2BB will convey the info I am after as I would rather upload a file to show what is needed but I posted a screenshot showing the menu and all other tabs.
I would like to have the Menu, Summary and a testing or more tabs show when I select a sheet.
Thank you

Menu.xlsm
H
9
Menu


1642454888601.png
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
So, when you enter or Select "All" in Range "C3" you want all your sheets shown is that correct?
But Excel does not allow you to hide all sheets. There must be one sheet visible.

And what are the other values you might want to select or enter into Range ("C3")

I assume you're using a Data Validation list in Range("C3")

So, will you only be using "All" or a specific sheet name?

Show me the code you're now using. You said:

"I found a solution to hide tabs that I don't need to show"
 
Upvote 0
Welcome to the MrExcel board!

Just a hint on using XL2BB: You need to select the range that you want to show before clicking 'Mini Sheet'
For example, if you had selected a range that included C2:C3, at least, then we would have been able to see what your Data Validation setting in C3 was (if there is one & providing you had 'Data Validation' checked in the XL2BB ribbon option)
 
Upvote 0
So, when you enter or Select "All" in Range "C3" you want all your sheets shown is that correct?
But Excel does not allow you to hide all sheets. There must be one sheet visible.

And what are the other values you might want to select or enter into Range ("C3")

I assume you're using a Data Validation list in Range("C3")

So, will you only be using "All" or a specific sheet name?

Show me the code you're now using. You said:

"I found a solution to hide tabs that I don't need to show"
Hi there,

Thank you for your reply and apologies for making the rookie mistakes.

Yes, on the menu tab is a dropdown list that comes from a data validation list on the Lists tab.
The list is just the tab names Summary, Testing 1, 2, 3...
My problem is that when I select Testing 1, all other tabs except the Menu and Testing 1 tab are hidden. Same goes for any other tab, it always only shows Menu plus selected tab.

What I would like to do is have a macro/code etc. that would give me the option of showing
1. Menu tab
2. Summary tab
3. Testing 1/2/3/4

i.e., a minimum of 3 tabs, if there is a possibility to select and show more testing tabs (as these are from different departments, and I need to calculate testing cost for multiple departments) that would make this XL sheet so much more useful.

Now the code I found is below (text in bold below is accompanying text/comment from the originator.

Menu Worksheet Code​

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  If Target.Address = Range("SelectType").Address Then
    Select Case Target.Value
      Case " All"
        ShowAllSheets
      Case ""
        'do nothing
      Case Else
        ShowSelSheets
        'do nothing
    End Select
  End If
End Sub

Show Sheets Macros​

The following macros are stored in a regular code module.

The ShowAllSheets macro runs when "ALL" is selected, and makes all the sheets visible.

VBA Code:
Sub ShowAllSheets()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Sheets
  ws.Visible = xlSheetVisible
Next ws
End Sub

The ShowSelSheets macro runs if any other option is selected, and it shows only the Menu sheet, and any sheet that has the selected text in its name.

VBA Code:
Sub ShowSelSheets()
Dim ws As Worksheet
Dim strType As String
strType = Worksheets("Menu").Range("SelectType").Value
For Each ws In ActiveWorkbook.Sheets
  If InStr(1, ws.Name, strType) > 0 Then
    ws.Visible = xlSheetVisible
  Else
    If ws.Name <> "Menu" Then
      ws.Visible = xlSheetHidden
    End If
  End If
Next ws
End Sub

XL2BB below

selectsheettype.xlsm
ABCDE
1
2Select a Sheet
3 All
4
5
6
7
8
9
Menu
Cells with Data Validation
CellAllowCriteria
C3List=SheetTypes
 
Upvote 0
Below is the code from the Lists tab

selectsheettype.xlsm
ABCDEF
1
2Type
3 All
4Testing 1
5Testing 2
6Testing 3
7Testing 4
8Summary
9
10
11
12
13
14
Admin_Lists
 
Upvote 0
What I would like to do is have a macro/code etc. that would give me the option of showing
1. Menu tab
2. Summary tab
3. Testing 1/2/3/4

i.e., a minimum of 3 tabs, if there is a possibility to select and show more testing tabs (as these are from different departments, and I need to calculate testing cost for multiple departments) that would make this XL sheet so much more useful.
I'm not really clear on that. Please address the following questions
  1. Do you want menu tab always visible? If not, how would you later select different tabs to be be visible?
  2. Do you want Summary tab always visible?
  3. Is sheet Admin_Lists from post #5 the same as sheet 'Lists' from the image in post #1?
    - If so, can you confirm what its actual name is?
    - If not can you clarify what the two sheets are?
  4. Should the Admin_Lists/Lists sheet(s) be hidden or visible as I note that they are not in the Data validation list?
  5. Do you want to be able to select multiple 'Testing' sheets to be visible at the same time?
 
Upvote 0
I like posters asking for a script to perform a Task. Then I write the code. It appears as if you have found some code and it does not do what you want and you want someone to modify the code to do what you want. I'm not good at that.

I would suggest putting the sheet names you want hidden in a Range and have the script run through that range and hide those sheets in the range and unhide all other sheets.

Like on sheet named "Alpha" Enter sheet names in column A for those sheets you want hidden.
The script would hide these sheets and unhide all others
If you wanted something like that I could help you with it.
And you could enter those sheet names using a Data Validation list.
 
Upvote 0
I'm not really clear on that. Please address the following questions
  1. Do you want menu tab always visible? If not, how would you later select different tabs to be be visible? Yes, that is the intent, Menu AND Summary Always visible
  2. Do you want Summary tab always visible? Yes, that is the intent, Menu AND Summary Always visible
  3. Is sheet Admin_Lists from post #5 the same as sheet 'Lists' from the image in post #1? Yes, the lists are the same, just renamed it
    - If so, can you confirm what its actual name is?
    - If not can you clarify what the two sheets are?
  4. Should the Admin_Lists/Lists sheet(s) be hidden or visible as I note that they are not in the Data validation list? should be hidden, but I can also move the list to the menu tab and move it to the far right so it is not visible
  5. Do you want to be able to select multiple 'Testing' sheets to be visible at the same time? If that is possible to have multiple such tabs show that would be great
 
Upvote 0
Welcome to the MrExcel Message Board!

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: https://www.myonlinetraininghub.com/excel-forum/vba-macros/question-on-creating-a-menu-tab
If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0

Forum statistics

Threads
1,215,518
Messages
6,125,293
Members
449,218
Latest member
Excel Master

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top