PC Review


Reply
Thread Tools Rate Thread

Activate hyperlink based on cell value

 
 
veggies27
Guest
Posts: n/a
 
      9th Apr 2009
I am trying to automatically activate a hyperlink if a certain cell has a
value in it. Is there a way this is possible?
 
Reply With Quote
 
 
 
 
Mike H
Guest
Posts: n/a
 
      9th Apr 2009
hi,

It would have helped to know which cells and where the hyperlink was going
but try this. Right click your sheet tab and view code and paste this in.
Enter 99 in a1 and a hyperling is created in b1 to sheet 1 a1

Private Sub Worksheet_Change(ByVal Target As Range)
If Range("A1").Value = 99 Then
ActiveSheet.Hyperlinks.Add Anchor:=Range("B1"), Address:="", _
SubAddress:="Sheet1!A1", TextToDisplay:="MyText"
End If
End Sub

Mike

"veggies27" wrote:

> I am trying to automatically activate a hyperlink if a certain cell has a
> value in it. Is there a way this is possible?

 
Reply With Quote
 
Mike H
Guest
Posts: n/a
 
      9th Apr 2009
Hi,

Similar solution

Private Sub Worksheet_Change(ByVal Target As Range)
If Range("A1").Value = 99 Then
Range("B1").Hyperlinks(1).Follow
End If
End Sub


Mike


"veggies27" wrote:

> Mike,
>
> Sorry for the vagueness.
>
> The hyperlink is already in Sheet 1, B1. I want the input of a "99" in ceel
> A1 to bring me to the place that the hyperlink in B1 is set to go.
>
> Jeff
>
> "veggies27" wrote:
>
> > I am trying to automatically activate a hyperlink if a certain cell has a
> > value in it. Is there a way this is possible?

 
Reply With Quote
 
veggies27
Guest
Posts: n/a
 
      9th Apr 2009
Mike,

One more try. For my spreadsheet, I converted the code to:

Private Sub Worksheet_Change(ByVal Target As Range)
If Range("E5").Value = X Then
Range("B5").Hyperlinks(1).Follow
End If
End Sub

However when I changed the "99" to an "X" it triggers the hyperlink when I
delete the X in the cell, not when I put the X in. Is that a text versus
numberic issue?


"Mike H" wrote:

> Hi,
>
> Similar solution
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> If Range("A1").Value = 99 Then
> Range("B1").Hyperlinks(1).Follow
> End If
> End Sub
>
>
> Mike
>
>
> "veggies27" wrote:
>
> > Mike,
> >
> > Sorry for the vagueness.
> >
> > The hyperlink is already in Sheet 1, B1. I want the input of a "99" in ceel
> > A1 to bring me to the place that the hyperlink in B1 is set to go.
> >
> > Jeff
> >
> > "veggies27" wrote:
> >
> > > I am trying to automatically activate a hyperlink if a certain cell has a
> > > value in it. Is there a way this is possible?

 
Reply With Quote
 
Mike H
Guest
Posts: n/a
 
      9th Apr 2009
Hi,

No problem we'll get there. using X in your code makes X a variable and not
the letter X. To make it the letter X put it in quotes like below. Now you
'may' encounter another problem because it becomes case sensitive so note how
i've included an UCASE statement so if you now enter x or X it works

Private Sub Worksheet_Change(ByVal Target As Range)
If UCase(Range("E5").Value) = "X" Then
Range("B5").Hyperlinks(1).Follow
End If
End Sub

Mike



"veggies27" wrote:

> Mike,
>
> One more try. For my spreadsheet, I converted the code to:
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> If Range("E5").Value = X Then
> Range("B5").Hyperlinks(1).Follow
> End If
> End Sub
>
> However when I changed the "99" to an "X" it triggers the hyperlink when I
> delete the X in the cell, not when I put the X in. Is that a text versus
> numberic issue?
>
>
> "Mike H" wrote:
>
> > Hi,
> >
> > Similar solution
> >
> > Private Sub Worksheet_Change(ByVal Target As Range)
> > If Range("A1").Value = 99 Then
> > Range("B1").Hyperlinks(1).Follow
> > End If
> > End Sub
> >
> >
> > Mike
> >
> >
> > "veggies27" wrote:
> >
> > > Mike,
> > >
> > > Sorry for the vagueness.
> > >
> > > The hyperlink is already in Sheet 1, B1. I want the input of a "99" in ceel
> > > A1 to bring me to the place that the hyperlink in B1 is set to go.
> > >
> > > Jeff
> > >
> > > "veggies27" wrote:
> > >
> > > > I am trying to automatically activate a hyperlink if a certain cell has a
> > > > value in it. Is there a way this is possible?

 
Reply With Quote
 
veggies27
Guest
Posts: n/a
 
      9th Apr 2009
Awesome! Thank you.

"Mike H" wrote:

> Hi,
>
> No problem we'll get there. using X in your code makes X a variable and not
> the letter X. To make it the letter X put it in quotes like below. Now you
> 'may' encounter another problem because it becomes case sensitive so note how
> i've included an UCASE statement so if you now enter x or X it works
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> If UCase(Range("E5").Value) = "X" Then
> Range("B5").Hyperlinks(1).Follow
> End If
> End Sub
>
> Mike
>
>
>
> "veggies27" wrote:
>
> > Mike,
> >
> > One more try. For my spreadsheet, I converted the code to:
> >
> > Private Sub Worksheet_Change(ByVal Target As Range)
> > If Range("E5").Value = X Then
> > Range("B5").Hyperlinks(1).Follow
> > End If
> > End Sub
> >
> > However when I changed the "99" to an "X" it triggers the hyperlink when I
> > delete the X in the cell, not when I put the X in. Is that a text versus
> > numberic issue?
> >
> >
> > "Mike H" wrote:
> >
> > > Hi,
> > >
> > > Similar solution
> > >
> > > Private Sub Worksheet_Change(ByVal Target As Range)
> > > If Range("A1").Value = 99 Then
> > > Range("B1").Hyperlinks(1).Follow
> > > End If
> > > End Sub
> > >
> > >
> > > Mike
> > >
> > >
> > > "veggies27" wrote:
> > >
> > > > Mike,
> > > >
> > > > Sorry for the vagueness.
> > > >
> > > > The hyperlink is already in Sheet 1, B1. I want the input of a "99" in ceel
> > > > A1 to bring me to the place that the hyperlink in B1 is set to go.
> > > >
> > > > Jeff
> > > >
> > > > "veggies27" wrote:
> > > >
> > > > > I am trying to automatically activate a hyperlink if a certain cell has a
> > > > > value in it. Is there a way this is possible?

 
Reply With Quote
 
veggies27
Guest
Posts: n/a
 
      24th Apr 2009
I've encountered another problem. When I use the code below, and type an "X"
in E5, it takes me right to the hyperlink location. However if the X stays in
E5 and I type anything anywhere else on the sheet, it activates the link too.
How can this code be modified to only activiate the hyperlink right after I
type the X in E5, and not all the time if an X exists in E5?

"Mike H" wrote:

> Hi,
>
> No problem we'll get there. using X in your code makes X a variable and not
> the letter X. To make it the letter X put it in quotes like below. Now you
> 'may' encounter another problem because it becomes case sensitive so note how
> i've included an UCASE statement so if you now enter x or X it works
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> If UCase(Range("E5").Value) = "X" Then
> Range("B5").Hyperlinks(1).Follow
> End If
> End Sub
>
> Mike
>
>
>
> "veggies27" wrote:
>
> > Mike,
> >
> > One more try. For my spreadsheet, I converted the code to:
> >
> > Private Sub Worksheet_Change(ByVal Target As Range)
> > If Range("E5").Value = X Then
> > Range("B5").Hyperlinks(1).Follow
> > End If
> > End Sub
> >
> > However when I changed the "99" to an "X" it triggers the hyperlink when I
> > delete the X in the cell, not when I put the X in. Is that a text versus
> > numberic issue?
> >
> >
> > "Mike H" wrote:
> >
> > > Hi,
> > >
> > > Similar solution
> > >
> > > Private Sub Worksheet_Change(ByVal Target As Range)
> > > If Range("A1").Value = 99 Then
> > > Range("B1").Hyperlinks(1).Follow
> > > End If
> > > End Sub
> > >
> > >
> > > Mike
> > >
> > >
> > > "veggies27" wrote:
> > >
> > > > Mike,
> > > >
> > > > Sorry for the vagueness.
> > > >
> > > > The hyperlink is already in Sheet 1, B1. I want the input of a "99" in ceel
> > > > A1 to bring me to the place that the hyperlink in B1 is set to go.
> > > >
> > > > Jeff
> > > >
> > > > "veggies27" wrote:
> > > >
> > > > > I am trying to automatically activate a hyperlink if a certain cell has a
> > > > > value in it. Is there a way this is possible?

 
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
Activate / deactivate a link based on the value of a cell Michael Lanier Microsoft Excel Programming 0 21st Jul 2009 03:16 PM
Re: Activate hyperlink based on cell value Chip Pearson Microsoft Excel Programming 0 9th Apr 2009 09:24 PM
RE: Activate hyperlink based on cell value veggies27 Microsoft Excel Programming 0 9th Apr 2009 08:44 PM
Activate macro based on cell value LB79 Microsoft Excel Misc 1 7th Sep 2004 04:39 PM
Activate Cell Based On Test Result fogbom Microsoft Excel Worksheet Functions 1 19th Jan 2004 09:03 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:36 PM.