-
-
Save johnBrooksHoffman/3c4ccb86e5de3c349e30 to your computer and use it in GitHub Desktop.
This is a simple Excel macro that converts a selection of cells into hyperlinks. It's intended for use on large blocks of URLs stored as plain text.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub Hyperlinker() | |
Dim rng As Range, workingRng As Range | |
Set workingRng = Application.Selection | |
'Code to set boundaries for workingRng, in case user selects entire row, column, or sheet | |
Set workingRng = Range(Cells(workingRng.Row, workingRng.Column), Cells(lastRowInColumn(workingRng.Column), lastColumnInRow(workingRng.Row))) | |
For Each rng In workingRng | |
Application.ActiveSheet.Hyperlinks.Add rng, rng.Value | |
Next rng | |
End Sub | |
Private Function lastRowInColumn(columnRef As Long) As Long | |
lastRowInColumn = Cells(65536, columnRef).End(xlUp).Row | |
End Function | |
Private Function lastColumnInRow(rowRef As Long) As Long | |
lastColumnInRow = Cells(rowRef, Columns.Count).End(xlToLeft).Column | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment