If you find any post useful then, please do share with others. Thanks!

Popular Posts

Contact

Email me

Need help and that also free? I like to learn this way, in case of any question or for a small task, please feel free to email me with details and example data, if required.

Thursday, August 4, 2016

Macro to add hyperlink for a list (Excel VBA)

We can use the below Excel Macro to add hyperlinks for a list. For example, we have a list of text to display and in next column a list of websites. This Macro will add the respective website as hyperlink.
So in our active sheet, in column 'A', we have some text which we want to be hyperlinked to website available in next column. Here in this Macro the list length is 6, which we can change as per our requirement.

Column A                            Column B

Tutorial on Excel
Tutorial on SQL
Tutorial on VBA
Tutorial on Java
Tutorial on HTML
Tutorial on REGEX

The data will look like this after running the Macro; the Column A is hyperlinked now.


And below is the VBA Code/Macro
Sub Amiq()
With ActiveSheet
Dim counter As Integer
counter = 1
Do While counter <= 6
.Hyperlinks.Add Anchor:=.Cells(counter, "A"), _
 Address:=Cells(counter, "B").Value, _
 ScreenTip:="Web Site", _
 TextToDisplay:=Cells(counter, "A").Value
counter = counter + 1
 Loop
 End With
End Sub


No comments:

Post a Comment