PDA

View Full Version : Solved: Auto Hyperlink to Folders



Hapten
05-08-2012, 05:27 PM
Hey,

I am using this 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 = 2 Then
Application.EnableEvents = False
FullPathName = "H:\Lab\" & Target
Target.Clear

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


End Sub


Everything works the way I want it, but one thing. Instead of displaying the "Full Path Name," I want it to display the folder name only. Looked everywhere and could not figure out what to do. Any insight into this would be welcomed.

Thank you.

geekgirlau
05-08-2012, 09:02 PM
Address:=FullPathName, TextToDisplay:=Mid(FullPathName, InstrRev(FullPathName,"\")+1)

Hapten
05-08-2012, 09:46 PM
Thanks geekgirlau, that is exactly what I needed. Here is a picture of a rabbit to show my appreciation.


.( Y )
.( . .)
c( ")(")

geekgirlau
05-09-2012, 06:15 PM
You're welcome - don't forget to mark the thread as solved (Thread Tools at the top of the page)