Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default ComboBox Code Problems

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.
Im 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)

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default ComboBox Code Problems

You are using Offset incorrectly. What is the relationship between links and
macros, how does the code know which the user picks?

--
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)



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default ComboBox Code Problems

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)



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default ComboBox Code Problems

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)




  #5   Report Post  
Posted to microsoft.public.excel.programming
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)








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default ComboBox Code Problems

Hi Bob,
You were right - the compile error cleared. I also made a correction in
the ranges - F1:F86 to F81:F86, etc - which is allowing the hyperlink case to
work properly. The macro case is not working though - Runtime error 1004:
The macro 'Sub GoTo.....()' cannot be found. Macro names, located in Module
2 because they operate for all worksheets, are correct (recopied/pasted
names, and retested). The entire line:
Application.Run _
Range("G81:G86").Cells(ComboBox1.ListIndex + 1, 1).Value

is highlighted yellow. With the "Range("G81......).Value" poriton proven
correct for the hyperlink case, Excel must object to the Application.Run
syntax. ???

Phil
"Bob Phillips" wrote:

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 (Text appearing in ComboBox)
F81:F86 Action (Text: Hyperlink, or, Run Macro)
G81:G86 Value (Hyperlinks, or, Macro names)







  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default ComboBox Code Problems

It doesn't object to that bit, I tested it and it worked fine.

I am not sure what this means

.... Macro names, located in Module 2 because they operate for all
worksheets, are correct (recopied/pasted names, and retested).

Your combobox is a controls toolbox combo on the worksheet I am assuming?

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Phil H" wrote in message
...
Hi Bob,
You were right - the compile error cleared. I also made a correction in
the ranges - F1:F86 to F81:F86, etc - which is allowing the hyperlink case

to
work properly. The macro case is not working though - Runtime error 1004:
The macro 'Sub GoTo.....()' cannot be found. Macro names, located in

Module
2 because they operate for all worksheets, are correct (recopied/pasted
names, and retested). The entire line:
Application.Run _
Range("G81:G86").Cells(ComboBox1.ListIndex + 1, 1).Value

is highlighted yellow. With the "Range("G81......).Value" poriton proven
correct for the hyperlink case, Excel must object to the Application.Run
syntax. ???

Phil
"Bob Phillips" wrote:

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 (Text appearing in ComboBox)
F81:F86 Action (Text: Hyperlink, or, Run Macro)
G81:G86 Value (Hyperlinks, or, Macro names)









  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default ComboBox Code Problems

Another thought, do the subs have arguments (parameters)?

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Phil H" wrote in message
...
Hi Bob,
You were right - the compile error cleared. I also made a correction in
the ranges - F1:F86 to F81:F86, etc - which is allowing the hyperlink case

to
work properly. The macro case is not working though - Runtime error 1004:
The macro 'Sub GoTo.....()' cannot be found. Macro names, located in

Module
2 because they operate for all worksheets, are correct (recopied/pasted
names, and retested). The entire line:
Application.Run _
Range("G81:G86").Cells(ComboBox1.ListIndex + 1, 1).Value

is highlighted yellow. With the "Range("G81......).Value" poriton proven
correct for the hyperlink case, Excel must object to the Application.Run
syntax. ???

Phil
"Bob Phillips" wrote:

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 (Text appearing in ComboBox)
F81:F86 Action (Text: Hyperlink, or, Run Macro)
G81:G86 Value (Hyperlinks, or, Macro names)









Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ComboBox Problems trini Excel Programming 1 September 9th 05 08:45 PM
Problems with Combobox MBais[_2_] Excel Programming 3 July 25th 05 01:37 PM
ComboBox Problems Darrin Henry[_2_] Excel Programming 1 April 15th 05 10:07 PM
ComboBox problems !! Jako[_24_] Excel Programming 4 June 21st 04 04:52 AM
ComboBox Problems Darrin Henry Excel Programming 1 September 16th 03 01:23 AM


All times are GMT +1. The time now is 01:27 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"