Forum Discussion
if Cell A contains any value in Col 1, Cell B = The header of that Col
- Nov 07, 2023
To achieve this in Excel, you can use the INDEX and MATCH functions. Assuming your data is in columns A, B, and C, and you want the result in cell D1, you can use the following formula:
=IF(ISNUMBER(MATCH(D1, A2:A4, 0)), B1, IF(ISNUMBER(MATCH(D1, B2:B4, 0)), C1, ""))
Here's how this formula works:
- MATCH(D1, A2:A4, 0) checks if the value in cell D1 (e.g., "Apple," "Pear," or "Orange") exists in the range A2:A4 (which contains "Apple," "Pear," and "Orange"). If there's a match, it returns the position of the match; otherwise, it returns an error.
- The ISNUMBER function checks if the result of the first MATCH function is a number (i.e., if there's a match in column A). If it's true, it means the value in D1 matches a value in column A, so it returns the corresponding value in cell B1 (e.g., "Alice").
- If the first MATCH didn't find a match in column A, the formula proceeds to the second MATCH(D1, B2:B4, 0) to check if there's a match in column B. If there's a match, it returns the value in C1 (e.g., "Bob").
- If there's no match in either column A or B, the formula returns an empty string ("").
You can place this formula in cell D1 and adjust the ranges and references as needed to match your actual data.The text was created with the help of AI.
My answers are voluntary and without guarantee!
Hope this will help you.
Was the answer useful? Mark as best response and like it!
This will help all forum participants.
To achieve this in Excel, you can use the INDEX and MATCH functions. Assuming your data is in columns A, B, and C, and you want the result in cell D1, you can use the following formula:
=IF(ISNUMBER(MATCH(D1, A2:A4, 0)), B1, IF(ISNUMBER(MATCH(D1, B2:B4, 0)), C1, ""))
Here's how this formula works:
- MATCH(D1, A2:A4, 0) checks if the value in cell D1 (e.g., "Apple," "Pear," or "Orange") exists in the range A2:A4 (which contains "Apple," "Pear," and "Orange"). If there's a match, it returns the position of the match; otherwise, it returns an error.
- The ISNUMBER function checks if the result of the first MATCH function is a number (i.e., if there's a match in column A). If it's true, it means the value in D1 matches a value in column A, so it returns the corresponding value in cell B1 (e.g., "Alice").
- If the first MATCH didn't find a match in column A, the formula proceeds to the second MATCH(D1, B2:B4, 0) to check if there's a match in column B. If there's a match, it returns the value in C1 (e.g., "Bob").
- If there's no match in either column A or B, the formula returns an empty string ("").
You can place this formula in cell D1 and adjust the ranges and references as needed to match your actual data.The text was created with the help of AI.
My answers are voluntary and without guarantee!
Hope this will help you.
Was the answer useful? Mark as best response and like it!
This will help all forum participants.
- wktayNov 07, 2023Copper Contributor
NikolinoDE tyvm