Solved

Create a hyperlink from selected cell using VBA

Posted on 2013-05-27
3
1,751 Views
Last Modified: 2013-05-28
Dear Experts:

below macro converts the selected cell (containing a file path)  into a hyperlink. How does this code have to be re-written so that the hyperlink is created in the cell next to the selected cell so that the initially selected cell is not changed

Example:

Cell A1: C:\test\myfile.xls

After running the macro the sheet looks like this:
Cell A1: C:\test\myfile.xls
Cell B1: C:\test\myfile.xls (converted into a hyperlink)

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

Regards, Andreas

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

Open in new window

0
Comment
Question by:AndreasHermle
3 Comments
 
LVL 35

Assisted Solution

by:[ fanpages ]
[ fanpages ] earned 250 total points
ID: 39199346
Hi Andreas,

Please try this:

Sub ConvertToHyperlink()

    ActiveSheet.Hyperlinks.Add Anchor:=Excel.Selection.Offset(,1), Address:=ActiveCell.Value, TextToDisplay:=ActiveCell.Value

End Sub

Open in new window


BFN,

fp.
0
 
LVL 33

Accepted Solution

by:
Norie earned 250 total points
ID: 39199576
Replace Excel.Selection with ActiveCell.Offset(,1).
0
 

Author Closing Comment

by:AndreasHermle
ID: 39202234
Dear Experts:

both codes work just fine.

Thank you very much for your great help.

Regards, andreas
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Office 2016 without internet 6 38
Excel format formula for currency 15 22
VBA question, how many data set exists in the sheet 14 57
excel formula to sum column 13 12
Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

773 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