Wednesday, May 11, 2011

VB macro to create excel url hotlink from filename

Here's a VB classic (circa VBA 2000) excel macro to automatically take filename text and create a file:// url out of it, making the cell into a hotlink. specs: Filenames are in column a Starts at row 2, processing 100 rows Skips empty entries

Sub tourl()
    Range("a2").Select
    For i = 1 To 100
        s = Selection.Value
        If s = "" Then GoTo EndNext

        'create excel hotlink            
        ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="h:\recorded tv\" & s

EndNext:
        Selection.Offset(1).Select

    Next
End Sub

No comments:

Post a Comment