Extract numbers from series.

motilulla

Well-known Member
Joined
Feb 13, 2008
Messages
2,422
Office Version
  1. 2010
Hello,

Extract number from string B, conditions is after 3 & 1, and put them in column D
In the column A just crosses are shown which numbers to be extracted from column B

Like this example

[TABLE="width: 384"]
<tbody>[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]Nºs[/TD]
[TD] [/TD]
[TD]After 3-1[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]3[/TD]
[TD] [/TD]
[TD]1[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]1[/TD]
[TD] [/TD]
[TD]3[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]1[/TD]
[TD] [/TD]
[TD]1[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]1[/TD]
[TD] [/TD]
[TD]2[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]3[/TD]
[TD] [/TD]
[TD]3[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]3[/TD]
[TD] [/TD]
[TD]1[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]2[/TD]
[TD] [/TD]
[TD]3[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]3[/TD]
[TD] [/TD]
[TD]1[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]1[/TD]
[TD] [/TD]
[TD]1[/TD]
[TD] [/TD]
[/TR]
[TR]
[T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TR]
[TR]
[TD] [/TD]
[TD]1[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]1[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]1[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]1[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
</tbody><colgroup><col><col><col><col><col></colgroup>[/TABLE]


Thank you all
Excel 2000
Regards,
Moti
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Try:

D1: =IFERROR(INDEX(B:B,SMALL(IF($B$1:$B$100=3,IF($B$2:$B$101=1,ROW($B$3:$B$102))),ROWS($D$1:$D1))),"")
change the ranges to match your sheet, confirm with Control+Shift+Enter. Copy down the column.
 
Upvote 0
Try:

D1: =IFERROR(INDEX(B:B,SMALL(IF($B$1:$B$100=3,IF($B$2:$B$101=1,ROW($B$3:$B$102))),ROWS($D$1:$D1))),"")
change the ranges to match your sheet, confirm with Control+Shift+Enter. Copy down the column.
Hello Eric, as I haven't got "IFERROR" I tried to change formula as bellow
D1: =IF(ISERROR(INDEX(B:B,SMALL(IF($B$1:$B$100=3,IF($B$2:$B$101=1,ROW($B$3:$B$102))),ROWS($D$1:$D1)))),"")
It is giving a result in D1 & down = FALSE

Regards,
Moti
 
Upvote 0
You could just remove the IFERROR like this:

=INDEX(B:B,SMALL(IF($B$1:$B$100=3,IF($B$2:$B$101=1,ROW($B$3:$B$102))),ROWS($D$1:$D1)))
with Control+Shift+Enter, and then just ignore any errors you get on the end of the list,

or you could create a helper cell that counts how many matches there are, and adapt the formula like this:


Excel 2012
ABCDE
NºsAfter 3-1
x
x
x

<colgroup><col style="width: 25pxpx"><col><col><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]
[TD="align: right"][/TD]

[TD="align: right"][/TD]

[TD="align: right"][/TD]

[TD="align: center"]2[/TD]
[TD="align: right"][/TD]
[TD="align: right"]3[/TD]
[TD="align: right"][/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]15[/TD]

[TD="align: center"]3[/TD]
[TD="align: right"][/TD]
[TD="align: right"]1[/TD]
[TD="align: right"][/TD]
[TD="align: right"]3[/TD]
[TD="align: right"][/TD]

[TD="align: center"]4[/TD]

[TD="align: right"]1[/TD]
[TD="align: right"][/TD]
[TD="align: right"]1[/TD]
[TD="align: right"][/TD]

[TD="align: center"]5[/TD]
[TD="align: right"][/TD]
[TD="align: right"]1[/TD]
[TD="align: right"][/TD]
[TD="align: right"]1[/TD]
[TD="align: right"][/TD]

[TD="align: center"]6[/TD]
[TD="align: right"][/TD]
[TD="align: right"]3[/TD]
[TD="align: right"][/TD]
[TD="align: right"]2[/TD]
[TD="align: right"][/TD]

[TD="align: center"]7[/TD]
[TD="align: right"][/TD]
[TD="align: right"]3[/TD]
[TD="align: right"][/TD]
[TD="align: right"]3[/TD]
[TD="align: right"][/TD]

[TD="align: center"]8[/TD]
[TD="align: right"][/TD]
[TD="align: right"]2[/TD]
[TD="align: right"][/TD]
[TD="align: right"]1[/TD]
[TD="align: right"][/TD]

[TD="align: center"]9[/TD]
[TD="align: right"][/TD]
[TD="align: right"]3[/TD]
[TD="align: right"][/TD]
[TD="align: right"]3[/TD]
[TD="align: right"][/TD]

[TD="align: center"]10[/TD]
[TD="align: right"][/TD]
[TD="align: right"]1[/TD]
[TD="align: right"][/TD]
[TD="align: right"]3[/TD]
[TD="align: right"][/TD]

[TD="align: center"]11[/TD]

[TD="align: right"]3[/TD]
[TD="align: right"][/TD]
[TD="align: right"]1[/TD]
[TD="align: right"][/TD]

[TD="align: center"]12[/TD]
[TD="align: right"][/TD]
[TD="align: right"]1[/TD]
[TD="align: right"][/TD]
[TD="align: right"]1[/TD]
[TD="align: right"][/TD]

[TD="align: center"]13[/TD]
[TD="align: right"][/TD]
[TD="align: right"]1[/TD]
[TD="align: right"][/TD]
[TD="align: right"]1[/TD]
[TD="align: right"][/TD]

[TD="align: center"]14[/TD]
[TD="align: right"][/TD]
[TD="align: right"]1[/TD]
[TD="align: right"][/TD]
[TD="align: right"]2[/TD]
[TD="align: right"][/TD]

[TD="align: center"]15[/TD]
[TD="align: right"][/TD]
[TD="align: right"]1[/TD]
[TD="align: right"][/TD]
[TD="align: right"]3[/TD]
[TD="align: right"][/TD]

[TD="align: center"]16[/TD]
[TD="align: right"][/TD]
[TD="align: right"]1[/TD]
[TD="align: right"][/TD]

[TD="align: right"][/TD]

[TD="align: center"]17[/TD]
[TD="align: right"][/TD]
[TD="align: right"]3[/TD]
[TD="align: right"][/TD]

[TD="align: right"][/TD]

[TD="align: center"]18[/TD]
[TD="align: right"][/TD]
[TD="align: right"]1[/TD]
[TD="align: right"][/TD]

[TD="align: right"][/TD]

[TD="align: center"]19[/TD]

[TD="align: right"]1[/TD]
[TD="align: right"][/TD]

[TD="align: right"][/TD]

[TD="align: center"]20[/TD]
[TD="align: right"][/TD]
[TD="align: right"]1[/TD]
[TD="align: right"][/TD]

[TD="align: right"][/TD]

</tbody>
Sheet2

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Array Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: #DAE7F5"]
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: #DAE7F5"]D2[/TH]
[TD="align: left"]{=IF(ROWS($D$2:$D2)>=$E$2,"",INDEX(B:B,SMALL(IF($B$2:$B$100=3,IF($B$3:$B$101=1,ROW($B$4:$B$102))),ROWS($D$2:$D2))))}[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #DAE7F5"]E2[/TH]
[TD="align: left"]{=SUM(IF($B$2:$B$100=3,IF($B$3:$B$101=1,1)))}[/TD]
[/TR]
</tbody>[/TABLE]
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself[/TD]
[/TR]
</tbody>[/TABLE]
 
Last edited:
Upvote 0
You could just remove the IFERROR like this:

=INDEX(B:B,SMALL(IF($B$1:$B$100=3,IF($B$2:$B$101=1,ROW($B$3:$B$102))),ROWS($D$1:$D1)))
with Control+Shift+Enter, and then just ignore any errors you get on the end of the list,

or you could create a helper cell that counts how many matches there are, and adapt the formula like this:


[TABLE="width: 85%"]
<tbody>[TR]
[TD]
Array Formulas[TABLE="width: 100%"]
<tbody>[TR]
[TH]Cell
[/TH]
[TH="align: left"]Formula
[/TH]
[/TR]
[TR]
[TH]D2
[/TH]
[TD="align: left"]{=IF(ROWS($D$2:$D2)>=$E$2,"",INDEX(B:B,SMALL(IF($B$2:$B$100=3,IF($B$3:$B$101=1,ROW($B$4:$B$102))),ROWS($D$2:$D2))))}
[/TD]
[/TR]
[TR]
[TH]E2
[/TH]
[TD="align: left"]{=SUM(IF($B$2:$B$100=3,IF($B$3:$B$101=1,1)))}
[/TD]
[/TR]
</tbody>[/TABLE]
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself[/TD]
[/TR]
</tbody>[/TABLE]
Excellent! Eric, Thank you very much for the help, your latest formula in D2 is resulting as treat. Also the formula you added in E2, which count matches, is helpful

Thank you for the explanation how to remove IFERROR. Also the previous formula you modified is working perfect

Have a pleasant day

Kind Regards,
Moti :)



 
Last edited:
Upvote 0
.. your latest formula in D2 is resulting as treat.
You should check that carefully as I think you will find it results in the last value being omitted unless you omit the red = sign below.

{=IF(ROWS($D$2:$D2)>=$E$2,"",INDEX(B:B,SMALL(IF($B$2:$B$100=3,IF($B$3:$B$101=1,ROW($B$4:$B$102))),ROWS($D$2:$D2))))}
 
Upvote 0
You should check that carefully as I think you will find it results in the last value being omitted unless you omit the red = sign below.

{=IF(ROWS($D$2:$D2)>=$E$2,"",INDEX(B:B,SMALL(IF($B$2:$B$100=3,IF($B$3:$B$101=1,ROW($B$4:$B$102))),ROWS($D$2:$D2))))}
Good catch Peter, yes it was missing last 1, just removed "=" and now extracting all 15

Thank you for observing it.

Kind Regards,
Moti :)


 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,320
Members
452,635
Latest member
laura12345

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