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
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.
=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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With