I would like to search a row for a string and get the column number if there is such a string.
Is this possible by using worksheet functions in Excel?
I would like to search a row for a string and get the column number if there is such a string.
Is this possible by using worksheet functions in Excel?
You can use MATCH
to give the position, e.g. you can search in row 2 for "xyz" like this
=MATCH("xyz",2:2,0)
If "xyz" is found first in J2 you get 10
if you want partial matches then you can use wildcards like
=MATCH("*xyz*",2:2,0)
so if F2 contains [abc xyz 344] you get a match with that and formula returns 6
I believe VLOOKUP
is the best for you.
There's also others like HLOOKUP
, LOOKUP
and SEARCH
Assuming you have something like this:
A1 A2 A3 A4
111 aaa sss bbb,
you could write something of this sort:
=FIND("$", CELL("address",OFFSET($A$2, 0,MATCH(111,A2:D2,1)-COLUMN($A$2)+1)), 2)
Ugly, but works (assuming that's what you were looking for)...