Hi Acharya ,
I am giving below , the general algorithm for solving this problem ; please tailor it to your requirements.
We need to define some named ranges :
1. Let us start with the data ; suppose your data is like this :
[pre]
Code:
1
2
3
4
5
7
8
9
12
13
14
15
16
11
[/pre]
where the numbers need not be in sequence.
Let us call this range Data_Range.
2. Now suppose in a separate part of your worksheet , you have defined the following two cells :
Start_Number , which defines the first number which is supposed to be present in your data range
Step_Size , which defines how the sequence is supposed to increment ; if your sequence increases in steps of 1 , this will be 1.
3. Let us define a named range One_To_Rows , which has the following formula in the Refers To box in the Name Manager : =ROW(INDIRECT(Start_Number&":"&(ROWS(Data_Range))))
What this does is define an array of numbers , which starts from Start_Number , and goes up in steps of 1 , till the number of rows in Data_Range.
4. Define a named range called Final_List , which has the following formula in the Refers To box in the Name Manager : =(One_To_Rows-1)*Step_Size+1
What this does is define the required array of numbers , based on Start_Number and Step_Size.
5. Now , in any unused cell , enter the following formula , entered as an array formula , using CTRL SHIFT ENTER , and copy down as far as you want :
=IFERROR(INDEX(Final_List,SMALL(IF(ISNA(MATCH(Final_List,Data_Range,0)),One_To_Rows),ROW(A1))),"")
Narayan