Convert Selected Cells into hyperlink using VBA

Posted on 2013-05-22
Medium Priority
Last Modified: 2013-05-23
Dear Experts:

For the currently selected cell(s) (may be just one cell selected or several) do the following running a macro:

Convert the currently selected cell(s) (Cells contain a network path such as C:\\myfolder\\etc.) ...
... into a hyperlink where the address and text to display is the same.

Help is much appreciated. Thank you very much in advance.

Regards, Andreas
Question by:Andreas Hermle
  • 2
LVL 22

Accepted Solution

rspahitz earned 2000 total points
ID: 39188231
Try this:

Sub ConvertToHyperlink()
    ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:= _
        ActiveCell.Value, TextToDisplay:=ActiveCell.Value
End Sub

Open in new window

When you run it, it will make the current cell a hyperlink to the contents of the cell.
Obviously, it does not validate that the current cell is a valid path.

Author Closing Comment

by:Andreas Hermle
ID: 39190973

Great this did the trick. Thank you very much for it.

Regards, Andreas
LVL 22

Expert Comment

ID: 39191233
Great!  Glad to help Andreas.

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
Microsoft's Excel has many features that most people will never need nor take advantage of.  Conditional formatting is one feature that you may find a necessity once you start using it.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question