The smallest range with the highest number of data

BrSuthe

New Member
Joined
Feb 10, 2018
Messages
29
I have some data like this:


DATA
1125591114141818292930373840406162
224469910121516173031354041455060
1455991010112525283035455051576068



The values are up to 100. No bigger values. Each row has 20 columns of data. No value repeats more than twice.
I need to find the smallest range with the high number of data in this range.

For example, for the first row, I calculated it by hand. my solution is like this:
Row1 : Range 1-18, and the number of data : 11

If it is easier, I can join all data in a single cell with textjoin.


DATA (alternative single cell version)
1,1,2,5,5,9,11,14,14,18,18,29,29,30,37,38,40,40,61,62
2,2,4,4,6,9,9,10,12,15,16,17,30,31,35,40,41,45,50,60
1,4,5,5,9,9,10,10,11,25,25,28,30,35,45,50,51,57,60,68


So if your solution requires such input, it is not a problem.

Here is a sample excel data: Book1.xlsx

thanks for your help!
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
I didn't understand:
You want the range of values? so why on Row 1 is not 1-62?
What did you mean by number of data 11?
 
Upvote 0
yes, I need the smallest range of values with the highest number of data from the list given. So it should be the peak where values are gathered in the range.

There are 11 values in this range (1 1 2 5 5 9 11 14 14 18 18).
so between 1 and 18 there are 11 numbers available.
 
Upvote 0
I can't see the logic yet, sorry. Altought I can't open files here.
Why not 1-62?
2nd row 2-60
3rd row 1-68
...
 
Upvote 0
Lets exemplify it like this:

if this is our list of numbers:

1 2 3 4 5 6 7 ... 9 ... 10 .........................................................40..................45.................50............53.... 58.......... etc...

and if we wanted to give the smallest range with highest numbers here, we would say 1- 10, right? not 9- 58 or 40 - 58, etc..

I don't need the whole list as the smallest range. it is the data, and i need to select the smallest range from the data.

Note: I didn't include repeating numbers in the above example. A value may repeat sometimes but not never more than twice.
 
Last edited:
Upvote 0
Are you looking for a single Targeted row... like this?
Book3
ABCDEFGHIJKLMNOPQRST
1StartEndRowStarting ColumnEnding ColumnTotal Count
21151199
3
4DATA
51125591114141818292930373840406162
6224469910121516173031354041455060
71455991010112525283035455051576068
Sheet1
Cell Formulas
RangeFormula
D2D2=SMALL((OFFSET(A4,C2,0,1,20)>(A2-1))*COLUMN(OFFSET(A4,C2,0,1,20)),1+COUNTIF(OFFSET(A4,C2,0,1,20),"<"&A2))
E2E2=LARGE((OFFSET(A4,C2,0,1,20)<(B2+1))*COLUMN(OFFSET(A4,C2,0,1,20)),1)
F2F2=E2-D2+1
 
Upvote 0
Or did you want it by row?
EDIT:D1:D2 can be deleted... irrelevant in this one
Book3
ABCDEFGHIJKLMNOPQRSTU
1StartEndRow
21151
3
4Total OccurancesDATA
591125591114141818292930373840406162
610224469910121516173031354041455060
791455991010112525283035455051576068
Sheet1
Cell Formulas
RangeFormula
A5:A7A5=LARGE((B5:T5<($C$2+1))*COLUMN(B5:T5),1)-SMALL((B5:T5>($B$2-1))*COLUMN(B5:T5),1+COUNTIF(B5:T5,"<"&$B$2))+1
 
Upvote 0
your formula works on row of data, right? I don't understand your post, sorry.
each row from A1:T1 is a set of data. A2:T2 is a second set of data.
 
Upvote 0
your formula works on row of data, right? I don't understand your post, sorry.
each row from A1:T1 is a set of data. A2:T2 is a second set of data.
My first example was the "Choose your own adventure" model...
In cells A2:C2, you set your low (1) high (15) and which row you want data from... So if you wanted to know how many between 10-15 in the 3rd row you could get that number

My second example sounds like what you wanted... the count of occurances by row... My formula calculates the total by row for each row, based on the high and low you set in cells A2, B2
 
Upvote 0

Forum statistics

Threads
1,215,390
Messages
6,124,667
Members
449,178
Latest member
Emilou

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