Bob Phillips wrote...
Here is a simple UDF you can use
Function URL(rng As Range)
If rng.Cells.Count 1 Then
URL = CVErr(xlErrRef)
Else
URL = rng.Hyperlinks(1).Address
End If
End Function
....
Perhaps too simple. As long as the range argument spans a single area
and fewer than 5,000-odd rows, why not return an array?
Function url(r As Range) As Variant
Dim rv As Variant, i As Long, j As Long
If r.Areas.Count = 1 And r.Areas(1).Cells.Count < 5100 Then
rv = r.Value
For i = 1 To r.Rows.Count
For j = 1 To r.Columns.Count
rv(i, j) = IIf(r.Cells(i, j).Hyperlinks.Count 0, _
r.Cells(i, j).Hyperlinks(1).Address, "")
Next j
Next i
Else
rv = CVErr(xlErrRef)
End If
If r.Cells.Count = 1 Then rv = rv(1, 1)
End Function
|