G
Guest
I am trying to make hyperlinks from list of addresses. I am using this
macro and am getting a "next without for" error at the end. Can someone tell
me what I need to do to fix this? Thanks,
Todd
Sub MakeHyperlinkFormulas()
Dim cell As Range
Dim hyperlinkaddress As String, hyperlinktext As String
For Each cell In Selection
hyperlinkaddress = Trim(cell.Text)
hyperlinktext = Trim(cell.Text)
If hyperlinktext = "" Then GoTo skipit
If hyperlinktext <> "" Then
If InStr(1, hyperlinkaddress, "@") Then
If LCase(Left(hyperlinkaddress, 7)) <> "mailto:" Then
hyperlinkaddress = "mailto:" & hyperlinkaddress
End If
Else
If InStr(1, hyperlinkaddress, ".") = 0 Then GoTo skipit
If LCase(Left(hyperlinkaddress, 7)) <> "http://" Then
hyperlinkaddress = "http://" & hyperlinkaddress
End If
End If
cell.Formula = "=HYPERLINK(""" & hyperlinkaddress & _
""",""" & hyperlinktext & """)"
skipit:
Next cell
End Sub
macro and am getting a "next without for" error at the end. Can someone tell
me what I need to do to fix this? Thanks,
Todd
Sub MakeHyperlinkFormulas()
Dim cell As Range
Dim hyperlinkaddress As String, hyperlinktext As String
For Each cell In Selection
hyperlinkaddress = Trim(cell.Text)
hyperlinktext = Trim(cell.Text)
If hyperlinktext = "" Then GoTo skipit
If hyperlinktext <> "" Then
If InStr(1, hyperlinkaddress, "@") Then
If LCase(Left(hyperlinkaddress, 7)) <> "mailto:" Then
hyperlinkaddress = "mailto:" & hyperlinkaddress
End If
Else
If InStr(1, hyperlinkaddress, ".") = 0 Then GoTo skipit
If LCase(Left(hyperlinkaddress, 7)) <> "http://" Then
hyperlinkaddress = "http://" & hyperlinkaddress
End If
End If
cell.Formula = "=HYPERLINK(""" & hyperlinkaddress & _
""",""" & hyperlinktext & """)"
skipit:
Next cell
End Sub