• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Return full cell contents if character exists within range

amp_82

New Member
Hi, I'm looking for a way to return a full cells value if it contains a certain character.


EG: I've a dataset where email address could be in any row from A-F and in column G I want to consolidate the emails so they are in a consistent column to later do a vlookup against

[pre]
Code:
123@abc	SAMPLE	SAMPLE	SAMPLE	SAMPLE	SAMPLE	        RESULT Column: 123@abc
SAMPLE	SAMPLE	bob@bob	SAMPLE	SAMPLE	SAMPLE	        RESULT Column: bob@bob
[/pre]
 
I think this will work:

=INDEX(A2:F2,SUMPRODUCT((ISNUMBER(FIND("@",A2:F2)))*(COLUMN(A2:F2))))
 
Not at all.

The FIND function looks at each of the cells and if the character we're looking for (@) is found, it gives an integer (representing the position within cell). If it's not found, it gives an error. The ISERROR function is then able to take this combination of errors and a single number into an array of True/False.

Then, that array gets multiplied against the column numbers. (a=1, b=2). Since there's only 1 True value, the SUMPRODUCT does 1*1+0*2+0*3+0*4+0*5 = 1.

The INDEX function then takes that number (1) and knows to looks at the 1st cell within the range. Does that help?
 
Doh!

Kudos to you Haseeb. I had completely forgotten that VLOOKUP and HLOOKUP can use wildcards. =)
 
wow, have been using v/hlookups daily for years, never knew they could support wild-cards, is how I first tried to solve this and then gave up!


Hats off to both of you. Many thanks.
 
Back
Top