Link to home
Start Free TrialLog in
Avatar of Knightsman
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!

ASKER CERTIFIED SOLUTION
Avatar of Cory Vandenberg
Cory Vandenberg
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Knightsman
Knightsman

ASKER

Thats what I needed!  Thanks!  

I wanted to post a spreadsheet, but its on a government computer and were nto allowed to upload items.  
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?
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?
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").Visible = True
ElseIf Range("G7") = "Trailer" Then
Sheets("Trailers").Visible = True

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