Adding hyperlinks using vba

haggisuk

New Member
Joined
Jan 26, 2008
Messages
10
Hi Folks,

I am trying to make a workbook that will basically be a document index to files on a network drive.

So what i wish to be able to do is have a button on the worksheet that will check for the next empty cell in a coloum and then open a browse window so i can look for a file on the network and then once i have selected the paticular file populate the next empty cell with the hyperlink to the file.

I can do the required tasks manually but i would like it run from a macro/vba sub

I tried to do it using a macro record sequence but cant get it to work.

Any ideas?

Thanks

Del
 
Last edited:

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Domski

Well-known Member
Joined
Jan 18, 2005
Messages
7,292
Hi,

Something like this maybe:

Code:
Sub test()
    Dim strFileName
    strFileName = Application.GetOpenFilename("All Files (*.*), *.*")
    If strFileName = False Then Exit Sub
    Sheets("Sheet1").Hyperlinks.Add Anchor:=Range("A" & Rows.Count).End(xlUp).Offset(1, 0), _
        Address:=strFileName, TextToDisplay:=strFileName
End Sub


Dom
 

haggisuk

New Member
Joined
Jan 26, 2008
Messages
10
Works a treat, Thanks very much.

I would have never have found that without asking.

Del
 

haggisuk

New Member
Joined
Jan 26, 2008
Messages
10
I have modified your code but works great for my needs

Sub Macro2()
Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).Select
Application.Dialogs(xlDialogInsertHyperlink).Show


End Sub


Thanks again for your help.

Del
 
Last edited:

Forum statistics

Threads
1,136,257
Messages
5,674,660
Members
419,521
Latest member
Jennifer4Dillon

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top