PC Review


Reply
Thread Tools Rate Thread

Assign macro to text in a cell rather than a control

 
 
Mack Neff
Guest
Posts: n/a
 
      6th Jun 2007
Is it possible to assign a macro to a word in a cell - like a hyperlink -
rather than to a control button?

 
Reply With Quote
 
 
 
 
NickHK
Guest
Posts: n/a
 
      6th Jun 2007
There's the Worksheet_FollowHyperlink event that is fired when a hyperlink
is clicked.
You can put code there.

NickHK

"Mack Neff" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Is it possible to assign a macro to a word in a cell - like a hyperlink -
> rather than to a control button?
>



 
Reply With Quote
 
Mack Neff
Guest
Posts: n/a
 
      6th Jun 2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> There's the Worksheet_FollowHyperlink event that is fired when a hyperlink
> is clicked.
> You can put code there.
>
> NickHK
>
> "Mack Neff" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Is it possible to assign a macro to a word in a cell - like a hyperlink -
>> rather than to a control button?
>>

>
>


 
Reply With Quote
 
NickHK
Guest
Posts: n/a
 
      6th Jun 2007
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" <(E-Mail Removed)> wrote in message
news:uL82Vi%(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > There's the Worksheet_FollowHyperlink event that is fired when a

hyperlink
> > is clicked.
> > You can put code there.
> >
> > NickHK
> >
> > "Mack Neff" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> >> Is it possible to assign a macro to a word in a cell - like a

hyperlink -
> >> rather than to a control button?
> >>

> >
> >

>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Assign Macro to a Cell Bob Myers Microsoft Excel Worksheet Functions 2 14th Dec 2009 07:35 PM
can I assign a macro to a cell? =?Utf-8?B?Sm9obiBNY01pY2hlYWw=?= Microsoft Excel Programming 3 14th Jun 2005 08:43 AM
assign a macro to a control button =?Utf-8?B?ZXdhbjcy?= Microsoft Excel Misc 1 3rd Dec 2004 02:04 PM
right click on cmd btn or macro btn, but no dialog box to assign control? Ian Elliott Microsoft Excel Misc 0 14th Aug 2003 05:54 PM
Re: Assign Macro to cell??? Ron de Bruin Microsoft Excel Programming 1 8th Aug 2003 04:23 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:50 PM.