Script to recognize hyperlinks?

  • Thread starter Thread starter jwb96
  • Start date Start date
J

jwb96

I'm using a for each...next loop to examine a range of cells that was
brought in through a web query. For each cell, I need to evaluate if
it's hyperlinked and if so, if it has text in it or is a blank cell
with a hyperlink or is a cell with text buy no hyperlink. What do I
put in my if statements to distinguish these possibilities?

TIA,
Jim
 
Maybe something like this will get you started:

Option Explicit
Sub testme()
Dim myCell As Range
Dim myRng As Range

Set myRng = ActiveSheet.Range("a1:a3")

For Each myCell In myRng.Cells

If myCell.Hyperlinks.Count > 0 Then
MsgBox "has link"
Else
MsgBox "no link"
End If

If IsEmpty(myCell.Value) Then
MsgBox "it's empty"
Else
MsgBox "it's not empty"
End If

Next myCell

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top