OfficeTips Home || VBA Section || General Section ||  Download Section  ||  Privacy Policy

Highlight all cells containing hyperlink in a sheet
 

A useful routine to select all the cells within a worksheet which contain hyperlinks.


 

' --------------------------------------------------------------------------------
' Copyright 1999-2014, Shyam Pillai, All Rights Reserved.
' --------------------------------------------------------------------------------
' You are free to use this code within your own applications, add-ins,
' documents etc but you are expressly forbidden from selling or
' otherwise distributing this source code without prior consent.
' This includes both posting free demo projects made from this
' code as well as reproducing the code in text or html format.
' --------------------------------------------------------------------------------

Sub SelectAllHyperlinkCells()

Dim LinkRange As Range
Dim Link As Hyperlink
Dim IsFirstCellInRange As Boolean


IsFirstCellInRange = True
If ActiveSheet.Hyperlinks.Count > 0 Then

For Each Link In ActiveSheet.Hyperlinks

If IsFirstCellInRange = True Then

Set LinkRange = Link.Range
IsFirstCellInRange = False

Else

Set LinkRange = Application.Union(LinkRange, Link.Range)

End If

Next Link

LinkRange.Select

End If

End Sub


 

 


 


' --------------------------------------------------------------------------------
' Copyright 1999-2014, Shyam Pillai, All Rights Reserved.
' --------------------------------------------------------------------------------
' You are free to use this code within your own applications, add-ins,
' documents etc but you are expressly forbidden from selling or
' otherwise distributing this source code without prior consent.
' This includes both posting free demo projects made from this
' code as well as reproducing the code in text or html format.
' --------------------------------------------------------------------------------


 

 

Copyright 1999-2014 (c) Shyam Pillai. All rights reserved.