I'm sure this question, or similar has been asked before. What I'm attempting to do is provide the user of the spreadsheet with a list in the form of a drop down. Also, depending on the selection from the list it will display a message box relevant to that selection. To elaborate: If "Alpha" is selected, a message box will appear with something like "Good to Go!" but if "Beta" is selected, the message box will display "N/A Proceed to Cell XX". I, unfortunately don't have much experience coding. I can insert the combo box and link it to a range of cells for the list. I know how to open the VBA window but after that, I'm lost. Thank you in advance for your help!
Combo Box Macro
- Algus
- Thread is marked as Resolved.
-
-
-
Re: Combo Box Macro
Algus - welcome to Ozgrid. Why not post a workbook with what you've done to date (or a mock up) and I'm sure somebody will be able to help you.
-
Re: Combo Box Macro
So I messed around with it and was able to generate a message but I'm still a little confused. The message displays regardless of selection. This is what I have so far.
-
Re: Combo Box Macro
Haven't got a clue about the logic of this.
Code
Display MoreSub ListSelect() ' ' ListSelecct Macro ' dimSelection = strn If strn = "Alpha" Then MsgBox "You may proceed" End If ' If strn = D22 Then MsgBox "Denied" End If End Sub
What is that 'dimSelection'? A typo or a variable name?
As it stands, you will always get the 'Denied' message as dimSelection will always be empty - never equal to "Alpha" and always equal to cell D22 which is also empty. How about you just use words to describe what you want it to do? Forget about code for a minute.
-
Re: Combo Box Macro
As an example, how to determine the selected value and display a message for each. One option is ignored, no message displayed.
Code
Display MoreSub ListSelect() ' ' ListSelecct Macro ' Dim strMsg As String Select Case ActiveSheet.Shapes("Drop Down 2").ControlFormat.List(ActiveSheet.Shapes("Drop Down 2").ControlFormat.ListIndex) Case "Alpha" strMsg = "Good to go" Case "Hotel" strMsg = "Please do something" Case "Zulu", "Yankee" strMsg = ActiveSheet.Shapes("Drop Down 2").ControlFormat.List(ActiveSheet.Shapes("Drop Down 2").ControlFormat.ListIndex) End Select ' One selection ignored - so no messagebox If strMsg <> vbNullString Then MsgBox strMsg, vbInformation End If ' dimSelection = strn ' If strn = "Alpha" Then ' MsgBox "You may proceed" ' End If ' ' ' If strn = D22 Then ' MsgBox "Denied" ' End If End Sub
-
Re: Combo Box Macro
Quote from Grimes0332;767705As an example, how to determine the selected value and display a message for each. One option is ignored, no message displayed.
Code
Display MoreSub ListSelect() ' ' ListSelecct Macro ' Dim strMsg As String Select Case ActiveSheet.Shapes("Drop Down 2").ControlFormat.List(ActiveSheet.Shapes("Drop Down 2").ControlFormat.ListIndex) Case "Alpha" strMsg = "Good to go" Case "Hotel" strMsg = "Please do something" Case "Zulu", "Yankee" strMsg = ActiveSheet.Shapes("Drop Down 2").ControlFormat.List(ActiveSheet.Shapes("Drop Down 2").ControlFormat.ListIndex) End Select ' One selection ignored - so no messagebox If strMsg <> vbNullString Then MsgBox strMsg, vbInformation End If ' dimSelection = strn ' If strn = "Alpha" Then ' MsgBox "You may proceed" ' End If ' ' ' If strn = D22 Then ' MsgBox "Denied" ' End If End Sub
This is it! Thank you so much! I don't really understand yet how it works but I can make significant progress with this. I'm still learning coding in VBA, thank you for bearing with me. Now all I have to do is find a way to set the list to an empty cell by clicking the Clear button I inserted earlier.
-
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!