Formula to List all numbers that appear 1 row below search target number

lesliewheeler

New Member
Joined
Dec 1, 2016
Messages
32
Office Version
  1. 2013
Platform
  1. Windows
Hi Friends,

I am looking for help with a formula basis the below condition:-

1. We have a list in column A approx 10000 row of numbers between 0 and 36 in a random manner
2. I would like to identify and list down all numbers that appear 1 row below our input/search target number, for e,g if our search criteria is 1 then the formula check the vertical list where 1 appears and returns the value of the cell one row below the target number. This is done for however many time the search number is appearing in the list. which means that if 1 is identified 500 times in the the list it will return all number which appeared below the number 1.
3. the desired search number can be entered in a cell

I have attached the sample excel with desired results for reference
test example.xlsx
CDEF
1List of NumbersSearch NumberResult
212125
3622
4521
52728
615
725
833
930
103
117
129
1323
1435
159
1615
1729
1817
1931
2036
2115
2230
2330
2415
2533
2627
279
2817
297
3027
3115
3211
332
3434
3535
368
3717
3832
3914
4033
4110
426
4334
4413
4531
4618
471
4822
4924
5022
5113
5222
5336
5425
5521
564
5729
5821
5926
6034
6128
6212
6336
6432
651
6621
6733
6819
6922
7010
7120
7221
7316
7414
7519
7629
7727
7822
7913
8027
8136
821
8328
8435
8534
8622
8733
8835
8916
9016
9135
9219
936
9418
954
9616
9717
989
997
1001
1015
Sheet1
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
Excel 2013
 
Upvote 0
Ok, how about
+Fluff 1.xlsm
ABC
1List of NumbersSearch NumberResult
212125
3622
4521
52728
615
725 
833 
930 
103 
117 
129 
1323 
1435 
159 
1615
1729
1817
1931
2036
2115
2230
2330
2415
2533
2627
279
2817
297
3027
3115
3211
332
3434
3535
368
3717
3832
3914
4033
4110
426
4334
4413
4531
4618
471
4822
4924
5022
5113
5222
5336
5425
5521
564
5729
5821
5926
6034
6128
6212
6336
6432
651
6621
6733
6819
6922
7010
7120
7221
7316
7414
7519
7629
7727
7822
7913
8027
8136
821
8328
8435
8534
8622
8733
8835
8916
9016
9135
9219
936
9418
954
9616
9717
989
997
1001
1015
Test
Cell Formulas
RangeFormula
C2:C15C2=IFERROR(INDEX($A$2:$A$101,AGGREGATE(15,6,(ROW($A$2:$A$101)-ROW($A$2)+1)/($A$2:$A$101=$B$2),ROWS(C$2:C2))+1),"")
 
Upvote 0
Ok, how about
+Fluff 1.xlsm
ABC
1List of NumbersSearch NumberResult
212125
3622
4521
52728
615
725 
833 
930 
103 
117 
129 
1323 
1435 
159 
1615
1729
1817
1931
2036
2115
2230
2330
2415
2533
2627
279
2817
297
3027
3115
3211
332
3434
3535
368
3717
3832
3914
4033
4110
426
4334
4413
4531
4618
471
4822
4924
5022
5113
5222
5336
5425
5521
564
5729
5821
5926
6034
6128
6212
6336
6432
651
6621
6733
6819
6922
7010
7120
7221
7316
7414
7519
7629
7727
7822
7913
8027
8136
821
8328
8435
8534
8622
8733
8835
8916
9016
9135
9219
936
9418
954
9616
9717
989
997
1001
1015
Test
Cell Formulas
RangeFormula
C2:C15C2=IFERROR(INDEX($A$2:$A$101,AGGREGATE(15,6,(ROW($A$2:$A$101)-ROW($A$2)+1)/($A$2:$A$101=$B$2),ROWS(C$2:C2))+1),"")
THANKS A MILLION TON FLUFF...worked like a charm....

Appreciate your support!!!!
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0
You're welcome & thanks for the feedback.
Hi Fluff,
Is there anyway a VBA code can be generated for the above formula...the excel has become very heavy and is taking ages to calculate on a data value change..
 
Upvote 0
How about
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   Dim Ary As Variant, Nary As Variant
   Dim r As Long, nr As Long
   
   If Target.CountLarge > 1 Then Exit Sub
   If Target.Address(0, 0) = "B2" Then
      Ary = Range("A2", Range("A" & Rows.Count).End(xlUp)).Value2
      ReDim Nary(1 To UBound(Ary), 1 To 1)
      For r = 1 To UBound(Ary)
         If Ary(r, 1) = Target.Value Then
            nr = nr + 1
            Nary(nr, 1) = Ary(r + 1, 1)
         End If
      Next r
      Range("c2").Resize(UBound(Nary)).Value = Nary
   End If
End Sub
This needs to go in the relevant sheet module & will trigger when B2 is changed.
 
Upvote 0
Solution
How about
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   Dim Ary As Variant, Nary As Variant
   Dim r As Long, nr As Long
  
   If Target.CountLarge > 1 Then Exit Sub
   If Target.Address(0, 0) = "B2" Then
      Ary = Range("A2", Range("A" & Rows.Count).End(xlUp)).Value2
      ReDim Nary(1 To UBound(Ary), 1 To 1)
      For r = 1 To UBound(Ary)
         If Ary(r, 1) = Target.Value Then
            nr = nr + 1
            Nary(nr, 1) = Ary(r + 1, 1)
         End If
      Next r
      Range("c2").Resize(UBound(Nary)).Value = Nary
   End If
End Sub
This needs to go in the relevant sheet module & will trigger when B2 is changed.

Thanks a ton Fluff....u have been a such a big help to me..

I sincerely appreciate your prompt response and assistance..

Thank you so much
 
Upvote 0

Forum statistics

Threads
1,214,632
Messages
6,120,649
Members
448,975
Latest member
sweeberry

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top