Phil,
"CB" is the name of the combobox, so change that to whatever you have called
your combobox. No need to Dim CB as ComboBox. And this code goes in the
CB_Click event, so it is fired when a selection is made.
You need to check the help for the structure of Select Case. See my example
and follow that.
Select Case [test expression]
Case [Value1]
'Do this if true
Case [Value2]
'Do this if true
....etc
Also, Help will explain how Offset work. It takes 2 arguments (rows,
columns)
The logic of this approach is that from whatever value is selected in the
combobox, you go down that many rows from the "K91" (given by CB.ListIndex),
then across to the "Action" column of that row.
You then see what should do; HLink or Macro are the 2 choices have at the
moment. So once you know that will e.g hyperlink, then code following "Case
"hlink"" will be run.
It would be easier if you did not used merged cells, as that makes it more
difficult to clearly see how many columns you have Offset to the right to
get to the Action and Value columns.
Unless anyone has any other ideas...
NickHK
Phil H said:
Nick, I have set up the following (using aliases in this discussion, testing
with actual hyperlinks and macro names).
Merged Cells TextToAppearingInCB
K91:O91 Policy ABC
K92:O92 Instruction XYZ
K93:O93 Note TUV
K94:O94 Directive HIJ
Cell Action
P91 HLink
P92 Macro
P93 HLink
P94 Macro
Merged Cells Value
Q91:U91 C:\Policies\Policy ABC (inserted hyperlink)
Q92:U92 Sub GoToXYZ() (inserted macro name)
Q93:U93 K:\Notes\Note TUV (inserted hyperlink)
Q94:U94 Sub GoToHIJ() (inserted macro name)
I'm not a programmer and could not find an example in a book of how to set
up the code - can you go further with me on this? Using Option Explicit, I'm
this far:
Sub ExecuteHyperlinkOrMacro()
Dim CB As ComboBox
With Range("K91")
Select Case LCase(.Offset(CB.ListIndex, 1).Value)
Select Case LCase(.Offset(CB.ListIndex, 2).Value)
Select Case LCase(.Offset(CB.ListIndex, 3).Value)
Select Case LCase(.Offset(CB.ListIndex, 4).Value)
End Select
End With
End Sub
Running this I get a compile error: "Statements and labels invalid between
Select Case and first case."