Min and Max on comma separated values in a cell

moishier

New Member
Joined
Mar 27, 2016
Messages
4
I have cells that contain comma separated number values. I need to extract the MIN and MAX numbers from each cell.

How can this be done?

I found this formula:

Code:
=MATCH(10,INDEX(FIND(","&ROW(INDIRECT("1:99999"))&",",","&AH13&","),0))

But it only gives me the MAX, not MIN.

I saw some VBA solutions but could not get them to work.
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
I have cells that contain comma separated number values.
Are the cells formatted as Text? If they are not, and depending on how large your values are, then you might not have a set of comma separated values, instead you might have a single number with thousands separators showing. So, can you tells us if your cells are formatted as Text? If not, can you show us a representative sample of the smallest set of numbers (least number of digits) you will have?
 
Upvote 0
found this formula:

Code:
=MATCH(10,INDEX(FIND(","&ROW(INDIRECT("1:99999"))&",",","&AH13&","),0))

But it only gives me the MAX, not MIN.
No, it does not give you the MAX - consider this... 123,5555,3333,45,2
 
Upvote 0
No, it does not give you the MAX - consider this... 123,5555,3333,45,2
But, assuming your cells contain TEXT values and not numeric values, these array-entered** formulas will give you the MAX and MIN...

Code:
[table="width: 500"]
[tr]
	[td]=MAX(0+TRIM(MID(SUBSTITUTE(","&A1,",",REPT(" ",300)),ROW(INDIRECT("1:"&1+LEN(A1)-LEN(SUBSTITUTE(A1,",",""))))*300,300)))

=MIN(0+TRIM(MID(SUBSTITUTE(","&A1,",",REPT(" ",300)),ROW(INDIRECT("1:"&1+LEN(A1)-LEN(SUBSTITUTE(A1,",",""))))*300,300)))[/td]
[/tr]
[/table]

**Commit these formulas using CTRL+SHIFT+ENTER and not just Enter by itself
 
Last edited:
Upvote 0
If you move the +0 inside the MIN, you can eliminate the TRIM

=MAX(0+MID(SUBSTITUTE(D3, ",", REPT(" ",255)), 255*(ROW(INDIRECT("1:"&(1+LEN(D3)-LEN(SUBSTITUTE(D3,",","")))))-1)+1,255))

=MIN(0+MID(SUBSTITUTE(D3, ",", REPT(" ",255)), 255*(ROW(INDIRECT("1:"&(1+LEN(D3)-LEN(SUBSTITUTE(D3,",","")))))-1)+1,255))
 
Last edited:
Upvote 0
Hi

I have the same problem. Is there a simpler formula to do this? I have some 40K rows on which this min/max has to be found. The machine simply hangs if i drag the formulae over so many rows.
 
Upvote 0
I have some 40K rows on which this min/max has to be found.
Could we have a small set of dummy (but representative) sample data (5-20 rows) using XL2BB including the expected results entered manually?

The machine simply hangs if i drag the formulae over so many rows.
Which formula? There has been quite a few suggested in the thread.
 
Upvote 0
DataExpected Result Min (Non Zero)Expected Result Max
3897,2561,0,0,0,0,0,0,,,,5767,4479,3221,0,0,0,0,0,295,295,,,,,3677,,,,,,,,,,,
295​
5767​
0,0,,0,0,0,0,0,
0​
0​
,
0​
0​
0,,,,,,,,,,,,,,
0​
0​
0,0,0,130,0,130,130,130,
130​
130​
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4267,1862,0,0,0,0,0,0,0,0,0,0,0,0,,,0,0,
1862​
4267​
0,0,1629,2705,3772,3167,1048,0,0,0,0,0,0,0,0,0,
1048​
3772​
0,76937,0,0,0,0,0,0,0,0,0,0,0,0,
0​
76937​
0,0,0,1047,0,1047,1047,1047,,,,
0​
1047​
 
Upvote 0
@Peter_SSs The Indirect(1:xxx) creates an array of numbers from 1 to xxx in each cell. When you do this in 40K rows, you have a very heavy file which cannot be handled easily. Each calculation cycle takes 5-10 seconds to happen even on fastest of laptops. All formulae which resort to this method have to be avoided. I am also looking at some other solutions to make the file lighter.
 
Upvote 0
How about
+Fluff 1.xlsm
ABC
1DataExpected Result Min (Non Zero)Expected Result Max
23897,2561,0,0,0,0,0,0,,,,5767,4479,3221,0,0,0,0,0,295,295,,,,,3677,,,,,,,,,,,2955767
30,0,,0,0,0,0,0,00
4,00
50,,,,,,,,,,,,,,00
60,0,0,130,0,130,130,130,0130
70,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4267,1862,0,0,0,0,0,0,0,0,0,0,0,0,,,0,0,18624267
80,0,1629,2705,3772,3167,1048,0,0,0,0,0,0,0,0,0,10483772
90,76937,0,0,0,0,0,0,0,0,0,0,0,0,076937
100,0,0,1047,0,1047,1047,1047,,,,01047
Main
Cell Formulas
RangeFormula
B2:B10B2=LET(f,FILTERXML("<k><m>"&SUBSTITUTE(TRIM(SUBSTITUTE(A2,","," "))," ","</m><m>")&"</m></k>","//m[.>0]"),IFERROR(IF(MAX(f)=MIN(f),0,MIN(f)),0))
C2:C10C2=LET(f,FILTERXML("<k><m>"&SUBSTITUTE(TRIM(SUBSTITUTE(A2,","," "))," ","</m><m>")&"</m></k>","//m[.>0]"),IFERROR(MAX(f),0))
 
Upvote 0

Forum statistics

Threads
1,223,250
Messages
6,171,036
Members
452,374
Latest member
keccles

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