Extract all cells from a column that meet criteria

yaniv_sa

New Member
Joined
Nov 4, 2018
Messages
7
Hey,
I have a colum A (in sheet '2174') that have this kind of data:

[TABLE="width: 79"]
<colgroup><col></colgroup><tbody>[TR]
[TD="align: right"]1335001410[/TD]
[/TR]
[TR]
[TD="align: right"]1335003990[/TD]
[/TR]
[TR]
[TD="align: right"]1341000930[/TD]
[/TR]
[TR]
[TD="align: right"]1341001790[/TD]
[/TR]
[TR]
[TD="align: right"]1341001930[/TD]
[/TR]
[TR]
[TD="align: right"]1341001990[/TD]
[/TR]
[TR]
[TD="align: right"]1341002930[/TD]
[/TR]
[TR]
[TD="align: right"]1341002990[/TD]
[/TR]
[TR]
[TD="align: right"]1341003930[/TD]
[/TR]
[TR]
[TD="align: right"]1841060182[/TD]
[/TR]
[TR]
[TD="align: right"]1841060471[/TD]
[/TR]
[TR]
[TD="align: right"]1842200760[/TD]
[/TR]
[TR]
[TD="align: right"]1842201840[/TD]
[/TR]
[TR]
[TD="align: right"]1842202841[/TD]
[/TR]
[TR]
[TD="align: right"]1842203840[/TD]
[/TR]
[TR]
[TD="align: right"]1842203841[/TD]
[/TR]
[TR]
[TD="align: right"]1842205840[/TD]
[/TR]
[TR]
[TD="align: right"]1842206840[/TD]
[/TR]
[TR]
[TD="align: right"]1842207810[/TD]
[/TR]
</tbody>[/TABLE]

i want to extract only number that meet this crateria to the main sheet (colum A):
if > 1600000000 and last 3 digits 930 or <1600000000 and last 3 digits are 840.
with out VBA

the result should be like this:
[TABLE="width: 79"]
<colgroup><col></colgroup><tbody>[TR]
[TD="align: right"]1341000930[/TD]
[/TR]
[TR]
[TD="align: right"]1341001930[/TD]
[/TR]
[TR]
[TD="align: right"]1341002930[/TD]
[/TR]
[TR]
[TD="align: right"]1341003930[/TD]
[/TR]
[TR]
[TD="align: right"]1842201840[/TD]
[/TR]
[TR]
[TD="align: right"]1842203840[/TD]
[/TR]
[TR]
[TD="align: right"]1842205840[/TD]
[/TR]
[TR]
[TD="align: right"]1842206840[/TD]
[/TR]
</tbody>[/TABLE]

I have tried may options with match and index but couldn't get it right.

please help.
 
thank you
i got an error in:
=sum(if('2174'!a2:a20<a1,if(right('2174'!a2:a20,3)+0=a2,1))+if('2174'!a2:a20>a1,if(right('2174'!a2:a20,3)+0=a3,1)))

when i have trid to add "," a20,a1 i get [table="width: 112"]
<tbody>[tr]
[td="width: 112, align: Right"]304000000[/td]
[/tr]
</tbody>[/table]

the condition should be =or(and(b2<1600000000,value(right(b2,3))=930),and(b2>1600000000,value(right(b2,3))=840))

can i do it in one cell (the table starts with a1 title, a2 data).

I have tried to do it like:
=if(rows($a$5:a5)>$a$4,"",index('2174'!a:a,small(if(('2174'!a:a < $a$1)*(right('2174'!a:a,3)+0=$a$2)+('2174'!a:a > $a$1)*(right('2174'!a:a,3)+0=$a$3),row('2174'!a:a)-row(index('2174'!a:a,1,1))+1),rows($a$5:a5))))

with control+shift+enter



</a1,if(right('2174'!a2:a20,3)+0=a2,1))+if('2174'!a2:a20></a1,if(right('2174'!a2:a20,3)+0=a2,1))+if('2174'!a2:a20>

a4:

=sum(if('2174'!a2:a20 < a1,if(right('2174'!a2:a20,3)+0=a2,1))+if('2174'!a2:a20 > a1,if(right('2174'!a2:a20,3)+0=a3,1)))

a5:

=if(rows($a$5:a5)>$a$4,"",index('2174'!$a$2:$a$20,small(if(('2174'!$a$2:$a$20 < $a$1)*(right('2174'!$a$2:$a$20,3)+0=$a$2)+('2174'!$a$2:$a$20 > $a$1)*(right('2174'!$a$2:$a$20,3)+0=$a$3),row('2174'!$a$2:$a$20)-row(index('2174'!$a$2:$a$20,1,1))+1),rows($a$5:a5))))
 
Upvote 0

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
If you are familiar with Power Query then you can use this M-Code.


Code:
let
    Source = Excel.CurrentWorkbook(){[Name="tbl_Data"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Number", Int64.Type}}),
    #"Duplicated Column" = Table.DuplicateColumn(#"Changed Type", "Number", "Number - Kopie"),
    #"Extracted Last Characters" = Table.TransformColumns(#"Duplicated Column", {{"Number - Kopie", each Text.End(Text.From(_, "de-DE"), 3), type text}}),
    #"Renamed Columns" = Table.RenameColumns(#"Extracted Last Characters",{{"Number - Kopie", "Last 3 digits"}}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Renamed Columns",{{"Last 3 digits", Int64.Type}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type1", each [Number] > 1600000000 and [Last 3 digits] = 840 or [Number] < 1600000000 and [Last 3 digits] = 930),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Last 3 digits"})
in
    #"Removed Columns"


Adapt Name="tbl_Data" to your need.




thank you very much, but i don't know Power Query, i prefer function like in this post.


A

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

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

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

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

[TD="align: center"]6[/TD]
[TD="align: right"]1341001930[/TD]

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

[TD="align: center"]8[/TD]
[TD="align: right"]1341002930[/TD]

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

[TD="align: center"]10[/TD]
[TD="align: right"]1341003930[/TD]

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

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

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

[TD="align: center"]14[/TD]
[TD="align: right"]1842201840[/TD]

[TD="align: center"]15[/TD]
[TD="align: right"]1842202841[/TD]

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

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

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

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

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

</tbody>
2174

A

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

[TD="align: center"]2[/TD]
[TD="align: right"]930[/TD]

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

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

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

[TD="align: center"]6[/TD]
[TD="align: right"]1341001930[/TD]

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

[TD="align: center"]8[/TD]
[TD="align: right"]1341003930[/TD]

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

[TD="align: center"]10[/TD]
[TD="align: right"]1842203840[/TD]

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

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

</tbody>
main

shift-del is right. We need to change the 1600000000 test in accordance with the results you want to obtain.


In A4 of main control+shift+enter, not just enter:

=SUM(IF('2174'!A2:A20<a1,if(right('2174'!a2:a20,3)+0=a2,1))+if('2174'!a2:a20>A1,IF(RIGHT('2174'!A2:A20,3)+0=A3,1)))

In A5 of main control+shift+enter, not just enter, and copy down:

=IF(ROWS($A$5:A5)>$A$4,"",INDEX('2174'!$A$2:$A$20,SMALL(IF(('2174'!$A$2:$A$20 < $A$1)*(RIGHT('2174'!$A$2:$A$20,3)+0=$A$2)+('2174'!$A$2:$A$20 > $A$1)*(RIGHT('2174'!$A$2:$A$20,3)+0=$A$3),ROW('2174'!$A$2:$A$20)-ROW(INDEX('2174'!$A$2:$A$20,1,1))+1),ROWS($A$5:A5))))

</a1,if(right('2174'!a2:a20,3)+0=a2,1))+if('2174'!a2:a20>
 
Upvote 0
a4:

=sum(if('2174'!a2:a20 < a1,if(right('2174'!a2:a20,3)+0=a2,1))+if('2174'!a2:a20 > a1,if(right('2174'!a2:a20,3)+0=a3,1)))

a5:

=if(rows($a$5:a5)>$a$4,"",index('2174'!$a$2:$a$20,small(if(('2174'!$a$2:$a$20 < $a$1)*(right('2174'!$a$2:$a$20,3)+0=$a$2)+('2174'!$a$2:$a$20 > $a$1)*(right('2174'!$a$2:$a$20,3)+0=$a$3),row('2174'!$a$2:$a$20)-row(index('2174'!$a$2:$a$20,1,1))+1),rows($a$5:a5))))



thank you very much, i guess it can't be done in 1 cell.
i modified the formola to :
A1: =SUM(IFERROR(IF('2174'!A2:A2000 < 1600000000,IF(RIGHT('2174'!A2:A2000,3)+0=930,1))+IF('2174'!A2:A2000 > 1600000000,IF(RIGHT('2174'!A2:A2000,3)+0=840,1)),0))
A2: =IF(ROWS($A$2:A2)>$A$1,"",INDEX('2174'!$A$2:$A$2000,SMALL(IF(IFERROR(('2174'!$A$2:$A$2000 < 1600000000)*(RIGHT('2174'!$A$2:$A$2000,3)+0=930)+('2174'!$A$2:$A$2000 > 1600000000)*(RIGHT('2174'!$A$2:$A$2000,3)+0=840),0),ROW('2174'!$A$2:$A$2000)-ROW(INDEX('2174'!$A$2:$A$2000,1,1))+1),ROWS($A$2:A2))))

it was very helpful.
 
Upvote 0
thank you very much, i guess it can't be done in 1 cell.
i modified the formola to :
A1: =SUM(IFERROR(IF('2174'!A2:A2000 < 1600000000,IF(RIGHT('2174'!A2:A2000,3)+0=930,1))+IF('2174'!A2:A2000 > 1600000000,IF(RIGHT('2174'!A2:A2000,3)+0=840,1)),0))
A2: =IF(ROWS($A$2:A2)>$A$1,"",INDEX('2174'!$A$2:$A$2000,SMALL(IF(IFERROR(('2174'!$A$2:$A$2000 < 1600000000)*(RIGHT('2174'!$A$2:$A$2000,3)+0=930)+('2174'!$A$2:$A$2000 > 1600000000)*(RIGHT('2174'!$A$2:$A$2000,3)+0=840),0),ROW('2174'!$A$2:$A$2000)-ROW(INDEX('2174'!$A$2:$A$2000,1,1))+1),ROWS($A$2:A2))))

it was very helpful.

It's cheaper to have a separate count cell for producing a sublist, but if you insist:


In A1 control+shift+enter, not just enter, and copy down:


=IFERROR(INDEX('2174'!$A$2:$A$2000,SMALL(IF(IFERROR(('2174'!$A$2:$A$2000 < 1600000000)*(RIGHT('2174'!$A$2:$A$2000,3)+0=930)+('2174'!$A$2:$A$2000 > 1600000000)*(RIGHT('2174'!$A$2:$A$2000,3)+0=840),0),ROW('2174'!$A$2:$A$2000)-ROW(INDEX('2174'!$A$2:$A$2000,1,1))+1),ROWS($A$1:A1))),"")
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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