Knightsman
asked on
Excel: Macro to load tabs based on cell data
I have a worksheet set for processing equipment. Trucks, trailers and containers.
However I want different tabs to load based on either truck, trailers, or containers.
User will choose by drop down list, and will click a macro button to initiate the macro and load the tabs.
Im stuck though, I cant figure out how to run it and load a different tab per cell value. Any help is appreciated!
However I want different tabs to load based on either truck, trailers, or containers.
User will choose by drop down list, and will click a macro button to initiate the macro and load the tabs.
Im stuck though, I cant figure out how to run it and load a different tab per cell value. Any help is appreciated!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I might have jumped to quick on that one.
how do I have macro check whether it says truck, trailer or container. And depending one which one unhide the truck, trailer or container tab?
how do I have macro check whether it says truck, trailer or container. And depending one which one unhide the truck, trailer or container tab?
ASKER
WAIT lol.
I meant, I missing somwhere on how to point the macro to the cell the dropdown menu is in..
Is it the Choice where I insert the cell range?
I meant, I missing somwhere on how to point the macro to the cell the dropdown menu is in..
Is it the Choice where I insert the cell range?
ASKER
This is my final. Thanks for your help. It led me in the right direction!
Private Sub Rectangle1_Click()
If Range("G7") = "Truck" Then
Sheets("Trucks").Visible = True
ElseIf Range("G7") = "Container" Then
Sheets("Containers").Visib le = True
ElseIf Range("G7") = "Trailer" Then
Sheets("Trailers").Visible = True
End If
End Sub
Private Sub Rectangle1_Click()
If Range("G7") = "Truck" Then
Sheets("Trucks").Visible = True
ElseIf Range("G7") = "Container" Then
Sheets("Containers").Visib
ElseIf Range("G7") = "Trailer" Then
Sheets("Trailers").Visible
End If
End Sub
Sorry, I was kind of busy yesterday, so just seeing your follow up. Yes, Choice is the range where the dropdown is located.
Instead of the if-elseif-elseif, a better coding procedure would probably be the
Select Case
No need to change it, but just so you know there is an alternative way of coding that.
Glad I could help,
WC
Instead of the if-elseif-elseif, a better coding procedure would probably be the
Select Case
No need to change it, but just so you know there is an alternative way of coding that.
Glad I could help,
WC
ASKER
I wanted to post a spreadsheet, but its on a government computer and were nto allowed to upload items.