are these doable?

etel777

New Member
Joined
Aug 20, 2011
Messages
3
- What if i have a set of numbers in a COLUMN: 8,9,7,2,3,8,6,4,9,7,6,1,4,6,5,3,1,6,5,3,7,8,9,4,6,7,8,3,7,3,2,6.

then i would like to pick a number , for example, 8, and then on a seperate COLUMN, i would like to have the values in the
cell after 8, = 9,6,9,3

- and also, on another COLUMN, i would like to show the cell counts before 8, = 0,4,15,4.

- and finally, i would like to show the cell count after the last cell which has the value 8, = 5

- can these be done on excel without counting them manually? thanx in advance... :)
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Welcome to the board!

- and finally, i would like to show the cell count after the last cell which has the value 8, = 5

The other formulas are beyond my current capabilities!
Excel Workbook
ABC
18,9,7,2,3,8,6,4,9,7,6,1,4,6,5,3,1,6,5,3,7,8,9,4,6,7,8,3,7,3,2,685
Sheet1
 
Upvote 0
If those numbers are in A1:A32 and 8 is in B1

1) Put this CSE formula (entered with Cntrl-Shift-Enter) in a cell and drag down
=INDEX(A:A, 1+MATCH(ROW(N1),COUNTIF(OFFSET($A$1,0,0,COLUMN($A$1:$BQ$1),1), $B$1),0), 1)

It returns 9; 6; 9; 3; #N/A;#N/A

2) if you put this CSE formula in a cell and drag down
=MATCH(ROW(N1),COUNTIF(OFFSET($A$1,0,0,COLUMN($A$100:$CQ$100),1),$B$1),0) - MATCH(ROW(N1)-1, COUNTIF(OFFSET($A$1,0,0,COLUMN($A$100:$CQ$100),1), $B$1),0)-1
you get #N/A; 4; 15; 4; #N/A

3)finaly this CSE formula
=MATCH(9999,A:A) - MATCH(MAX(COUNTIF(OFFSET($A$1,0,0,COLUMN($A$100:$CQ$100),1),$B$1)), COUNTIF(OFFSET($A$1,0,0,COLUMN($A$100:$CQ$100),1),$B$1), 0)
will return 5.

These formulas are easier to understand and edit if you use a Named value
Name: CountArray
RefersTo: =COUNTIF(OFFSET(Sheet2!$A$1,0,0,COLUMN(Sheet2!$A$100:$CQ$100),1),Sheet2!$B$1)

The formulae then become
1) =INDEX(A:A, 1+MATCH(ROW(N1), countArray, 0), 1)
2) =MATCH(ROW(N1), countArray, 0) - MATCH(ROW(N1)-1, countArray, 0)
3) =MATCH(9999, A:A) - MATCH(MAX(countArray), countArray, 0)
 
Upvote 0
Here's my go at it for what it's worth.

<br /><table cellpadding="2.5px" rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #A6AAB6"><colgroup><col width="25px" style="background-color: #E0E0F0" /><col /><col /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: #E0E0F0;text-align: center;color: #161120"><th></th><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th><th>F</th></tr></thead><tbody><tr ><td style="color: #161120;text-align: center;">1</td><td style="font-weight: bold;text-align: center;;">Data</td><td style="font-weight: bold;text-align: center;;">Data After</td><td style="font-weight: bold;text-align: center;;">Counts Before</td><td style="font-weight: bold;text-align: center;;">Count After Last</td><td style="text-align: center;;"></td><td style="font-weight: bold;text-align: center;;">Marker=</td></tr><tr ><td style="color: #161120;text-align: center;">2</td><td style="text-align: center;background-color: #CCFFCC;;">8</td><td style="text-align: center;;">9</td><td style="text-align: center;;">0</td><td style="text-align: center;;">5</td><td style="text-align: center;;"></td><td style="text-align: center;background-color: #CCFFCC;;">8</td></tr><tr ><td style="color: #161120;text-align: center;">3</td><td style="text-align: center;;">9</td><td style="text-align: center;;">6</td><td style="text-align: center;;">4</td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td></tr><tr ><td style="color: #161120;text-align: center;">4</td><td style="text-align: center;;">7</td><td style="text-align: center;;">9</td><td style="text-align: center;;">15</td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td></tr><tr ><td style="color: #161120;text-align: center;">5</td><td style="text-align: center;;">2</td><td style="text-align: center;;">3</td><td style="text-align: center;;">4</td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td></tr><tr ><td style="color: #161120;text-align: center;">6</td><td style="text-align: center;;">3</td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td></tr><tr ><td style="color: #161120;text-align: center;">7</td><td style="text-align: center;background-color: #CCFFCC;;">8</td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td></tr><tr ><td style="color: #161120;text-align: center;">8</td><td style="text-align: center;;">6</td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td></tr><tr ><td style="color: #161120;text-align: center;">9</td><td style="text-align: center;;">4</td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td></tr><tr ><td style="color: #161120;text-align: center;">10</td><td style="text-align: center;;">9</td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td></tr><tr ><td style="color: #161120;text-align: center;">11</td><td style="text-align: center;;">7</td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td></tr><tr ><td style="color: #161120;text-align: center;">12</td><td style="text-align: center;;">6</td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td></tr><tr ><td style="color: #161120;text-align: center;">13</td><td style="text-align: center;;">1</td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td></tr><tr ><td style="color: #161120;text-align: center;">14</td><td style="text-align: center;;">4</td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td></tr><tr ><td style="color: #161120;text-align: center;">15</td><td style="text-align: center;;">6</td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td></tr><tr ><td style="color: #161120;text-align: center;">16</td><td style="text-align: center;;">5</td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td></tr><tr ><td style="color: #161120;text-align: center;">17</td><td style="text-align: center;;">3</td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td></tr><tr ><td style="color: #161120;text-align: center;">18</td><td style="text-align: center;;">1</td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td></tr><tr ><td style="color: #161120;text-align: center;">19</td><td style="text-align: center;;">6</td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td></tr><tr ><td style="color: #161120;text-align: center;">20</td><td style="text-align: center;;">5</td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td></tr><tr ><td style="color: #161120;text-align: center;">21</td><td style="text-align: center;;">3</td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td></tr><tr ><td style="color: #161120;text-align: center;">22</td><td style="text-align: center;;">7</td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td></tr><tr ><td style="color: #161120;text-align: center;">23</td><td style="text-align: center;background-color: #CCFFCC;;">8</td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td></tr><tr ><td style="color: #161120;text-align: center;">24</td><td style="text-align: center;;">9</td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td></tr><tr ><td style="color: #161120;text-align: center;">25</td><td style="text-align: center;;">4</td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td></tr><tr ><td style="color: #161120;text-align: center;">26</td><td style="text-align: center;;">6</td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td></tr><tr ><td style="color: #161120;text-align: center;">27</td><td style="text-align: center;;">7</td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td></tr><tr ><td style="color: #161120;text-align: center;">28</td><td style="text-align: center;background-color: #CCFFCC;;">8</td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td></tr><tr ><td style="color: #161120;text-align: center;">29</td><td style="text-align: center;;">3</td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td></tr><tr ><td style="color: #161120;text-align: center;">30</td><td style="text-align: center;;">7</td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td></tr><tr ><td style="color: #161120;text-align: center;">31</td><td style="text-align: center;;">3</td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td></tr><tr ><td style="color: #161120;text-align: center;">32</td><td style="text-align: center;;">2</td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td></tr><tr ><td style="color: #161120;text-align: center;">33</td><td style="text-align: center;;">6</td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td></tr></tbody></table><br /><br /><table cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: #FFFFFF" ><tr><td style="padding:6px" ><b>Array Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: #FFFFFF;border-collapse: collapse; border-color: #A6AAB6"><thead><tr style=" background-color: #E0E0F0;color: #161120"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">B2</th><td style="text-align:left">{=IF(<font color="Blue">COUNTIF(<font color="Red">A:A,$F$2</font>)<ROW(<font color="Red">A1</font>),"",INDEX(<font color="Red">$A$2:$A$100,SMALL(<font color="Green">IF(<font color="Purple">$A$2:$A$100=$F$2,ROW(<font color="Teal">$A$2:$A$100</font>),""</font>),ROW(<font color="Purple">A1</font>)</font>)</font>)</font>)}</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">C2</th><td style="text-align:left">{=IF(<font color="Blue">COUNTIF(<font color="Red">A:A,$F$2</font>)<ROW(<font color="Red">A1</font>),"",SMALL(<font color="Red">IF(<font color="Green">$A$2:$A$100=$F$2,ROW(<font color="Purple">$A$2:$A$100</font>)-2,""</font>),ROW(<font color="Green">A1</font>)</font>)-IF(<font color="Red">ROW(<font color="Green">A1</font>)=1,0,SMALL(<font color="Green">IF(<font color="Purple">$A$2:$A$100=$F$2,ROW(<font color="Teal">$A$2:$A$100</font>)-1,""</font>),ROW(<font color="Purple">A1</font>)-1</font>)</font>)</font>)}</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">D2</th><td style="text-align:left">{=IF(<font color="Blue">COUNTIF(<font color="Red">A:A,F2</font>)=0,"",COUNT(<font color="Red">A2:A100</font>)-MAX(<font color="Red">IF(<font color="Green">A2:A100=F2,ROW(<font color="Purple">A2:A100</font>)</font>)</font>)+1</font>)}</td></tr></tbody></table><b>Entered with Ctrl+Shift+Enter.</b> If entered correctly, Excel will surround with curly braces {}.
<b>Note: Do not try and enter the {} manually yourself</b></td></tr></table><br />
 
Upvote 0
Maybe a macro approach?

<font face=Courier New><br><SPAN style="color:#00007F">Sub</SPAN> etel777()<br>    <SPAN style="color:#00007F">Dim</SPAN> a, b<br>    <SPAN style="color:#00007F">Dim</SPAN> After8 <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>, Before8 <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN><br>    <SPAN style="color:#00007F">Dim</SPAN> lr <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>, i <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>, x <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>, AfterLast8 <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN><br>    <br>    lr = Range("A" & Rows.Count).End(xlUp).Row<br>    <SPAN style="color:#00007F">With</SPAN> Range("A1:A" & lr)<br>        a = .Value<br>        <SPAN style="color:#00007F">For</SPAN> i = 1 <SPAN style="color:#00007F">To</SPAN> lr<br>            <SPAN style="color:#00007F">If</SPAN> i < lr And a(i, 1) = 8 <SPAN style="color:#00007F">Then</SPAN><br>                After8 = After8 & "," & a(i + 1, 1)<br>                Before8 = Before8 & "," & i - x - 1<br>                x = i<br>                AfterLast8 = 0<br>            <SPAN style="color:#00007F">ElseIf</SPAN> a(i, 1) = 8 <SPAN style="color:#00007F">Then</SPAN><br>                AfterLast8 = 0<br>            <SPAN style="color:#00007F">Else</SPAN><br>                AfterLast8 = AfterLast8 + 1<br>            <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br>        <SPAN style="color:#00007F">Next</SPAN> i<br>        b = Split(Replace(After8, ",", "", 1, 1, 1), ",")<br>        .Offset(, 1).Resize(UBound(b) + 1).Value = Application.Transpose(b)<br>        b = Split(Replace(Before8, ",", "", 1, 1, 1), ",")<br>        .Offset(, 2).Resize(UBound(b) + 1).Value = Application.Transpose(b)<br>        .Offset(, 3).Resize(1).Value = AfterLast8<br>    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>    <br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br></FONT>

Excel Workbook
ABCD
18905
2964
37915
4234
53
68
76
84
99
107
116
121
134
146
155
163
171
186
195
203
217
228
239
244
256
267
278
283
297
303
312
326
33
etel777
 
Upvote 0

Forum statistics

Threads
1,224,574
Messages
6,179,628
Members
452,933
Latest member
patv

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