Hi,
I'm hoping someone can help me with this. I've never really done VBA code before so I'm struggling to write something that works the way I intend it to. I have a drop down list in a cell on my "Client information" sheet (in cell C16). I have 7 total options - Please Select, 1, 2, 3, 4, 5 & 6. I then have 6 sheets named "Gift 1", "Gift 2".... etc. I would like all the gift sheets to be hidden when the Please Select option is chosen. If the sales rep chooses 1 from the list, I'd like only the Gift 1 sheet to appear. If they choose 2 from the list, I'd like Gift 1 & Gift 2 to appear and so on. I wrote the code below by lots of google searches, lots of copying & pasting and lots of blind tinkering. I managed to get this to work but only if each time a new selection is made from the list you manually run the macro. I'd like the macro to automatically run anytime a new selection is made from the drop down list. Can someone please advise me on what changes need to be made in order for this to happen automatically? It would be a bonus if someone could show me how to shorten this long code
Sub GiftTabs()
Select Case Worksheets("Client Information").Range("C16").Value
Case "Please Select"
Sheets("Gift 1").Visible = False
Sheets("Gift 2").Visible = False
Sheets("Gift 3").Visible = False
Sheets("Gift 4").Visible = False
Sheets("Gift 5").Visible = False
Sheets("Gift 6").Visible = False
Case "1"
Sheets("Gift 1").Visible = True
Sheets("Gift 2").Visible = False
Sheets("Gift 3").Visible = False
Sheets("Gift 4").Visible = False
Sheets("Gift 5").Visible = False
Sheets("Gift 6").Visible = False
Case "2"
Sheets("Gift 1").Visible = True
Sheets("Gift 2").Visible = True
Sheets("Gift 3").Visible = False
Sheets("Gift 4").Visible = False
Sheets("Gift 5").Visible = False
Sheets("Gift 6").Visible = False
Case "3"
Sheets("Gift 1").Visible = True
Sheets("Gift 2").Visible = True
Sheets("Gift 3").Visible = True
Sheets("Gift 4").Visible = False
Sheets("Gift 5").Visible = False
Sheets("Gift 6").Visible = False
Case "4"
Sheets("Gift 1").Visible = True
Sheets("Gift 2").Visible = True
Sheets("Gift 3").Visible = True
Sheets("Gift 4").Visible = True
Sheets("Gift 5").Visible = False
Sheets("Gift 6").Visible = False
Case "5"
Sheets("Gift 1").Visible = True
Sheets("Gift 2").Visible = True
Sheets("Gift 3").Visible = True
Sheets("Gift 4").Visible = True
Sheets("Gift 5").Visible = True
Sheets("Gift 6").Visible = False
Case "6"
Sheets("Gift 1").Visible = True
Sheets("Gift 2").Visible = True
Sheets("Gift 3").Visible = True
Sheets("Gift 4").Visible = True
Sheets("Gift 5").Visible = True
Sheets("Gift 6").Visible = True
End Select
End Sub
Thanks!
Pizza_Man
I'm hoping someone can help me with this. I've never really done VBA code before so I'm struggling to write something that works the way I intend it to. I have a drop down list in a cell on my "Client information" sheet (in cell C16). I have 7 total options - Please Select, 1, 2, 3, 4, 5 & 6. I then have 6 sheets named "Gift 1", "Gift 2".... etc. I would like all the gift sheets to be hidden when the Please Select option is chosen. If the sales rep chooses 1 from the list, I'd like only the Gift 1 sheet to appear. If they choose 2 from the list, I'd like Gift 1 & Gift 2 to appear and so on. I wrote the code below by lots of google searches, lots of copying & pasting and lots of blind tinkering. I managed to get this to work but only if each time a new selection is made from the list you manually run the macro. I'd like the macro to automatically run anytime a new selection is made from the drop down list. Can someone please advise me on what changes need to be made in order for this to happen automatically? It would be a bonus if someone could show me how to shorten this long code
Sub GiftTabs()
Select Case Worksheets("Client Information").Range("C16").Value
Case "Please Select"
Sheets("Gift 1").Visible = False
Sheets("Gift 2").Visible = False
Sheets("Gift 3").Visible = False
Sheets("Gift 4").Visible = False
Sheets("Gift 5").Visible = False
Sheets("Gift 6").Visible = False
Case "1"
Sheets("Gift 1").Visible = True
Sheets("Gift 2").Visible = False
Sheets("Gift 3").Visible = False
Sheets("Gift 4").Visible = False
Sheets("Gift 5").Visible = False
Sheets("Gift 6").Visible = False
Case "2"
Sheets("Gift 1").Visible = True
Sheets("Gift 2").Visible = True
Sheets("Gift 3").Visible = False
Sheets("Gift 4").Visible = False
Sheets("Gift 5").Visible = False
Sheets("Gift 6").Visible = False
Case "3"
Sheets("Gift 1").Visible = True
Sheets("Gift 2").Visible = True
Sheets("Gift 3").Visible = True
Sheets("Gift 4").Visible = False
Sheets("Gift 5").Visible = False
Sheets("Gift 6").Visible = False
Case "4"
Sheets("Gift 1").Visible = True
Sheets("Gift 2").Visible = True
Sheets("Gift 3").Visible = True
Sheets("Gift 4").Visible = True
Sheets("Gift 5").Visible = False
Sheets("Gift 6").Visible = False
Case "5"
Sheets("Gift 1").Visible = True
Sheets("Gift 2").Visible = True
Sheets("Gift 3").Visible = True
Sheets("Gift 4").Visible = True
Sheets("Gift 5").Visible = True
Sheets("Gift 6").Visible = False
Case "6"
Sheets("Gift 1").Visible = True
Sheets("Gift 2").Visible = True
Sheets("Gift 3").Visible = True
Sheets("Gift 4").Visible = True
Sheets("Gift 5").Visible = True
Sheets("Gift 6").Visible = True
End Select
End Sub
Thanks!
Pizza_Man