Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Assign macro to text in a cell rather than a control

Is it possible to assign a macro to a word in a cell - like a hyperlink -
rather than to a control button?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Assign macro to text in a cell rather than a control

There's the Worksheet_FollowHyperlink event that is fired when a hyperlink
is clicked.
You can put code there.

NickHK

"Mack Neff" wrote in message
...
Is it possible to assign a macro to a word in a cell - like a hyperlink -
rather than to a control button?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Assign macro to text in a cell rather than a control

OK... this is a start, but I'm really a novice at coding... so far have just
recorded macros and followed a few step-by-step VBA projects. Can you be a
bit more specific?


"NickHK" wrote in message
...
There's the Worksheet_FollowHyperlink event that is fired when a hyperlink
is clicked.
You can put code there.

NickHK

"Mack Neff" wrote in message
...
Is it possible to assign a macro to a word in a cell - like a hyperlink -
rather than to a control button?




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Assign macro to text in a cell rather than a control

1 - Select the worksheet you have the hyperlink(s) on.
2 - Right-click the WS tab. select "View Code".
3 - Select "Worksheet" from the top left combo box.
4 - Select "FollowHyperlink" from the top right combo box.

VBA will generate the event signature for you:
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
'You put your own code here
End Sub
"Target" gives you info on the hyperlink clicked.

There is also the related Workbook_SheetFollowHyperlink, which you can get
to by a similar process as above, but first double click the "ThisWorkbook"
module under your Project:
Private Sub Workbook_SheetFollowHyperlink(ByVal Sh As Object, ByVal Target
As Hyperlink)

End Sub
With this event, you can react to a hyperlink (Target) on any WS (Sh) in
that workbook.

NickHK

"Mack Neff" wrote in message
...
OK... this is a start, but I'm really a novice at coding... so far have

just
recorded macros and followed a few step-by-step VBA projects. Can you be a
bit more specific?


"NickHK" wrote in message
...
There's the Worksheet_FollowHyperlink event that is fired when a

hyperlink
is clicked.
You can put code there.

NickHK

"Mack Neff" wrote in message
...
Is it possible to assign a macro to a word in a cell - like a

hyperlink -
rather than to a control button?






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
How do I assign a numeric value to text? IE cell = yes then 1 rrr Excel Discussion (Misc queries) 7 September 28th 06 02:01 AM
how do i assign a value to a cell containing text Ani63 Excel Worksheet Functions 5 September 14th 06 08:41 PM
Assign values to text within a cell Bob Excel Worksheet Functions 2 June 7th 05 09:51 PM
Possible to assign macro defined as private to a form control. Bing Excel Programming 1 December 24th 04 06:08 AM
assign a macro to a control button ewan72 Excel Discussion (Misc queries) 1 December 3rd 04 02:04 PM


All times are GMT +1. The time now is 06:09 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"