Andreas Hermle
asked on
Create a hyperlink from selected cell using VBA
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
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
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
both codes work just fine.
Thank you very much for your great help.
Regards, andreas