A macro to count hyperlinks

Last Edited By Krjb Donovan
Last Updated: Mar 05, 2014 09:14 PM GMT

QuestionEdit

So basically what I am trying to do is to create a Macro that will go through a column inand count how many hyperlinks are in that column. Can this be done?

AnswerEdit

Sam Bruce:


To count the number of hyperlinks in column 9 (column "I") - change to your column

Sub countHyperlinks() Dim cnt As Long Dim hlink As Hyperlink For Each hlink In ActiveSheet.Hyperlinks

 If hlink.Parent.Column = 9 Then
   cnt = cnt + 1
 End If

Next MsgBox "number of hyperlinks in column I is " & cnt End Sub


if all the hyperlinks are in a single column then

Sub CountHyperlinksonsheet() MsgBox "number of hyperlinks is " & ActiveSheet.Hyperlinks.Count End Sub


Code should be in a general module in the visual basic editor. In the editor menu do Insert=>Module and put it in a module like that.

Advertisement

©2024 eLuminary LLC. All rights reserved.