Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

find a row index of a number that occurred first

Tags:

I have A column that has values in random order like

       A column            2            3            4            2            5            6            4            3            4 

I want the row index of a particular number that occurred first. say if i say the number is 4 the value returned should be 3

I also want the row index of a particular number that occured last.say if i say the number is 3 then the value returned must be 8

I was thinking Vlookup or find function must do the task but unable to put them in order.please help me with these

like image 694
niko Avatar asked Dec 07 '11 08:12

niko


People also ask

How do you find the first occurrence of a value in a row in Excel?

To count the first instance of items, you can use a formula to find all the first instance of values, and then count them. 1. Select a blank cell next to your data, and type this formula =(COUNTIF($A$1:$A1,$A1)=1)+0, press Enter key, and then drag the autofill handle down to the cell needed this formula.

How do I find a row index number in Excel?

=ROW([cell]) This function can be run with no arguments. If you do this, the function returns the row number of the cell that houses the function. If you include the optional cell argument, it returns the row number of the specified cell.

What is the row number index?

row-index-num is a row number in the same column of the table-array, a numeric value greater than or equal to 1 but less than the number of rows in the table-array. range-lookup-flag is an optional argument. It is a logical value: TRUE or FALSE.

How do I find the first cell with a specific value in Excel?

You can find the first non-blank cell in a range with the help of the ISBLANK, MATCH, and INDEX Functions. Note: This is an array formula. If you are using Excel 2019 or earlier, you must enter the formula with CTRL + SHIFT + ENTER instead of just ENTER.


1 Answers

My examples are looking for the number 3 but it is easy to adapt.

To find the first occurence, you can use:

=MATCH(3,A:A,0) 

To find the last one, you can use an array formula (validate with Ctrl+Shift+Enter)

{=MAX(IF(A1:A10=3,ROW(A1:A10),0))} 

Note that you could also have used an array formula for the first one with a MIN but it would be quite complicated for what it's worth.

like image 154
JMax Avatar answered Nov 15 '22 01:11

JMax