Reputation: 1348
I am trying to check whether values in a column, say A, contain a link, and if true, in column B, I want to type a text, for example: link. I have many records (10 000), so doing this by hand will take a lot of time. Thx.
Upvotes: 2
Views: 32637
Reputation: 1
As links (if we are speaking about links, not hyperlinks) are formulas, this should work (unless you also have formulas without links):
=IF(ISFORMULA(A1),"LINK","")
Upvotes: 0
Reputation: 1396
An aproximate solution without VBA:
=AND(ISREF(A1),ISNUMBER(SEARCH("http",A1,1)))
It is based on asking for two conditions:
Upvotes: 0
Reputation: 126
Function IsHyperlink(r As Range) As Integer IsHyperlink = r.Hyperlinks.Count End Function
Alt+Q
Use your new function with the if conditions to display your text:
=IF(IsHyperlink(A1),"LINK","NO LINK")
Upvotes: 10
Reputation: 1
There is a formula that could work, but it's based upon the length of the characters in the cell. For example, a hyperlink typically contains more characters due to the pathname. If the number of characters in your cells is always less than 30, for example, then you could write the formula
=If(Len(Cell("Filename",A1))>30,"True","False")
The formula will return "True" if the cell is a hyperlink. This formula assumes that the Excel file is stored in a subfolder where each folder name is referenced which adds to the length of the hyperlink.
Upvotes: 0
Reputation: 1348
I managed to find a formula, not on VBA.
I used =IF(HYPERLINK(A1>0), "WEB", "")
Thank you all for your time. :)
Upvotes: -5
Reputation: 4984
Here:
Sub Links()
Dim lnk As Hyperlink, lnks As Hyperlinks
Set lnks = Range("A:A").Hyperlinks
For i = 1 To lnks.Count
Set lnk = lnks(i)
lnk.Range.Value = "Link"
Next
End Sub
You need to read more on VBA if you want to use the procedure above. Please also always share your research first and at least a code stub. This was simple hence the exception.
Upvotes: 2