write excel formula to search for the first instance of negative value in a column and…
- User
write excel formula to search for the first instance of negative value in a column and return a different cell in the same row
- Assistant
To search for the first instance of a negative value in a column and return a different cell from the same row in Excel, you can use a combination of the
INDEX,MATCH, andIFfunctions. Here is a formula you can use:Assuming your data is in column
Aand you want to return a value from columnBwhen a negative value is found in columnA, you can use the following formula:=INDEX(B:B, MATCH(TRUE, A:A<0, 0))Here's what each part of the formula does:
-
A:A<0: This creates an array of Boolean values (TRUE if the cell in column A is negative, FALSE otherwise). -
MATCH(TRUE, A:A<0, 0): This finds the first occurrence ofTRUEin the array created byA:A<0, which corresponds to the first negative value in column A. The0indicates an exact match. -
INDEX(B:B, ...): This returns the value in column B that corresponds to the row number found by theMATCHfunction.
Make sure to adjust the column references if your data is in different columns or ranges.
-