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
Hi friend you may use macros to do this
Use the following code
How to use the code? (In case you are new to macro)
Open a new excel file
Press Alt + F11
Insert a new module
Paste the code into the module
Go back to the excel sheet and add a button
Assign the macro ‘FindNumbers’ to the button
Save excel in .xlsm format if you are using excel 2007 or 2010
Help
Column A: Enter your data in column A and click the button or run the macro
Press the button or run the macro
Your result will be like this
Column B: Numbers that are unique in the data entered in Column A
Column C: First occurrence of data
Column D: Last occurrence of data
My examples are looking for the number
3
but it is easy to adapt.To find the first occurence, you can use:
To find the last one, you can use an array formula (validate with Ctrl+Shift+Enter)
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.