Hi
I am currently doing a project for the civil engineering company i work for in Cumbria. It involves the following roads: M6, M55, A66, A595, A590, A585. At the minute, i have a combo box with the all the roads that can be chosen and I am trying to make it so that depending on which road they choose from the combo box, something relevant will happen. Before i jump right in to this however, i was trying to simplify it and get the knowledge behind it.
To simplify it, i just tried to make a macro that made a message box appear with whatever option was chosen in the combo box when it was run.
Sub Macro1()
Select Case ComboBox1.Value
Case "M6"
MsgBox "M6"
Case "M55"
MsgBox "M55"
Case "A66"
MsgBox "A66"
Case "A595"
MsgBox "A595"
Case "A590"
MsgBox "A590"
Case "A585"
MsgBox "A585"
End Select
End Sub
I have tried searching and reading and i cant find out what i am doing wrong so i tried a different approach and simplified it even more. I tried to make it so if the M6 was selected then a message box would appear saying "M6" and with everything else, it would just bring up a blank message box (didnt know how to make it do nothing). So i entered this:
Sub Macro1()
If Sheet1.ComboBox1.Value = "M6"
Then MsgBox ("M6")
Else: MsgBox ("")
End If
End Sub
Can anyone help direct me to what i am doing wrong in both cases as i am very new to programming and advise to which way is the best way to go about this? Thanks in advance.
I am currently doing a project for the civil engineering company i work for in Cumbria. It involves the following roads: M6, M55, A66, A595, A590, A585. At the minute, i have a combo box with the all the roads that can be chosen and I am trying to make it so that depending on which road they choose from the combo box, something relevant will happen. Before i jump right in to this however, i was trying to simplify it and get the knowledge behind it.
To simplify it, i just tried to make a macro that made a message box appear with whatever option was chosen in the combo box when it was run.
Sub Macro1()
Select Case ComboBox1.Value
Case "M6"
MsgBox "M6"
Case "M55"
MsgBox "M55"
Case "A66"
MsgBox "A66"
Case "A595"
MsgBox "A595"
Case "A590"
MsgBox "A590"
Case "A585"
MsgBox "A585"
End Select
End Sub
I have tried searching and reading and i cant find out what i am doing wrong so i tried a different approach and simplified it even more. I tried to make it so if the M6 was selected then a message box would appear saying "M6" and with everything else, it would just bring up a blank message box (didnt know how to make it do nothing). So i entered this:
Sub Macro1()
If Sheet1.ComboBox1.Value = "M6"
Then MsgBox ("M6")
Else: MsgBox ("")
End If
End Sub
Can anyone help direct me to what i am doing wrong in both cases as i am very new to programming and advise to which way is the best way to go about this? Thanks in advance.