View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default ComboBox Code Problems

Just NG wrap-around I think

Private Sub ComboBox1_Click()
With ThisWorkbook.ActiveSheet.Range("A79")
Select Case Range("F1:F86").Cells(ComboBox1.ListIndex + 1, 1).Value
Case "Hyperlink"
ThisWorkbook.FollowHyperlink _
Range("G1:G86").Cells(ComboBox1.ListIndex + 1, 1).Value
Case "Run Macro"
Application.Run _
Range("G1:G86").Cells(ComboBox1.ListIndex + 1, 1).Value
Case Else
MsgBox "Other Action not currently supported.", _
vbInformation + vbOKOnly, "Info"
End Select
End With
End Sub

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Phil H" wrote in message
...
Hi Bob,

Thanks for your reply. Having the same compile error on

FollowHyperlink...

Phil
"Bob Phillips" wrote:

Looking at it again, I think that this might be what you want

Private Sub ComboBox1_Click()
With ThisWorkbook.ActiveSheet.Range("A79")
Select Case Range("F1:F86").Cells(ComboBox1.ListIndex, 1).Value
Case "Hyperlink"
ThisWorkbook.FollowHyperlink
Range("G1:G86").Cells(ComboBox1.ListIndex + 1, 1).Value
Case "Run Macro"
Application.Run Range("G1:G86").Cells(ComboBox1.ListIndex +

1,
1).Value
Case Else
MsgBox "Other Action not currently supported.",

vbInformation +
vbOKOnly, "Info"
End Select
End With
End Sub



--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Phil H" wrote in message
...
The following code is held in ComboBox1 click event. It is intended

when
the
user clicks on one of the choices, either a hyperlink or macro is

executed.
I'm getting a compile error: Argument not optional. On the fifth

line,
the
following code is highlighted: .FollowHyperlink

Can someone suggest a fix?

Private Sub ComboBox1_Click()
With ThisWorkbook.ActiveSheet.Range("A79")
Select Case (.Offset(ComboBox1.ListIndex, 4).Value)
Case "Hyperlink"
ThisWorkbook.FollowHyperlink.Offset(ComboBox1.List Index,

6).Value
Case "Run Macro"
Application.Run.Offset(ComboBox1.ListIndex, 6).Value
Case Else
MsgBox "Other Action not currently supported.",

vbInformation
+
vbOKOnly, "Info"
End Select
End With
End Sub
Operating addresses:

Cell Function
A79 ComboBox Linked Cell
A81:A86 ListFill Range
F81:F86 Action (Text: Hyperlink, or, Run Macro)
G81:G86 Value (Hyperlinks, or, Macro names)