Donate

Change Cell Url Contents To Hyperlinks Using VBA In MS Excel

Hello!

Assuming in your MS Excel Worksheet you have thousands of cells that contains url and you want them to be a hyperlink. It can be done manually, but tedious. Another solution is to write a VBA (Visual Basic for Applications) Script to do that for you using the Sub procedure below that will convert an Excel cell content to hyperlink.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
Sub ChangeCellsToHyperlinks()  
   Dim rng As Range  
   Dim ctr As Integer  
   Dim range_name As String  
   ctr = 2 'starting cell to change  
   Do While ctr <= 10000 'end cell range  
     Set rng = ActiveSheet.Range("A" & ctr)  
     rng.Parent.Hyperlinks.Add Anchor:=rng, Address:=rng  
     With rng.Font  
       .ColorIndex = 25  
       .Underline = xlUnderlineStyleSingle  
     End With  
     ctr = ctr + 1  
   Loop  
 End Sub

That's it!

Comments

Donate

Popular Posts From This Blog

WPF CRUD Application Using DataGrid, MVVM Pattern, Entity Framework, And C#.NET

How To Insert Or Add Emojis In Microsoft Teams Status Message

TypeScript Error Or Bug: The term 'tsc' is not recognized as the name of a cmdlet, function, script file, or operable program.