So I basically have a table with multiple columns.
So for each of the ids (1, 2, 3), I would like to check in which column there is sub-string of * (as you see sometimes it’s in B and sometimes in C). Then I would like to extract the whole string that contains * and is associated with the given ID.
Suppose that my actual table contains over 10 columns – but the idea remains the same.
In other words the entries that I am looking for that contain a specific substring are scatted all throughout the 10 different columns.
Since the asterisk(*) is a wildcard we need to append it with the tilde(~) to tell Search to look for the actual character.
* allow the HLOOKUP to look at part.
Try the following User Defined Function:
Public Function FindTheStar(rng As Range) As String Dim r As Range, v As String FindTheStar = "" For Each r In rng v = r.Text If InStr(v, "*") > 0 Then FindTheStar = v Exit Function End If Next r End Function
It will find and return the first cell in any range that contains an asterisk.