Automatic Hyperlink?


Posted by Chris on March 25, 2001 10:45 AM

Can anyone tell me if there's a way to have just one column "automatically hyperlink" all numbers entered to it corresponding foldername stored in a directory on my harddrive -- for example:


34525 ---> hyperlink(c:\windows\34525)

Dave - this is similar to (www.mrexcel.com/wwwboard/messages/12251.html)
but for hyperlinks.

Any help greatly appreciated,
Chris

Posted by Dave Hawley on March 25, 2001 7:24 PM

Hi Chris

No problem, all we need to do is place the code below in the Worksheet Change Event (right click on sheet name tab and select "View Code")

Private Sub Worksheet_Change(ByVal Target As Range)
Dim FullPathName As String
If Target.Cells.Count > 1 Then Exit Sub
If Target = "" Then Exit Sub

If Target.Column = 1 Then
Application.EnableEvents = False
FullPathName = "C:\windows\" & Target
Target.Clear

Target.Hyperlinks.Add Anchor:=Target, _
Address:=FullPathName, TextToDisplay:=FullPathName
Application.EnableEvents = True
End If

End Sub


This will turn ALL entries entered into Column A into a hperlink.

Dave


OzGrid Business Applications

Posted by Chris on March 26, 2001 12:59 PM

great!

to make the cell "text to display" equal what is entered what do I need to add to this code?

Thanks Dave!


Posted by Dave Hawley on March 26, 2001 4:54 PM


Chris, removing "Target.Clear" should do it.

Dave


OzGrid Business Applications



Posted by Chris on March 27, 2001 4:23 PM

Thanks Dave - you've been a huge help!