sorting lottery numbers numerically

mark91345

Board Regular
Joined
Feb 11, 2011
Messages
113
In Excel 2010, I want to sort the lottery numbers (Balls 1 -4) numerically (as it shows in NewBall 1-4). Note that I do NOT want them concatenated into one column, as I need them to remain separate.

What do you recommend?
<table rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #BBB" cellpadding="2.5px"><colgroup><col style="background-color: #DAE7F5" width="25px"><col><col><col><col><col><col><col><col><col><col></colgroup><thead><tr style=" background-color: #DAE7F5;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><th>G</th><th>H</th><th>I</th><th>J</th></tr></thead><tbody><tr><td style="color: #161120;text-align: center;">1</td><td style=";">DATE</td><td style="text-align: center;;">Ball1</td><td style="text-align: center;;">Ball2</td><td style="text-align: center;;">Ball3</td><td style="text-align: center;;">Ball4</td><td style="text-align: right;background-color: #A6A6A6;;">
</td><td style="text-align: center;;">NewBall1</td><td style="text-align: center;;">NewBall2</td><td style="text-align: center;;">NewBall3</td><td style="text-align: center;;">NewBall4</td></tr><tr><td style="color: #161120;text-align: center;">2</td><td style=";">Mon. Apr 02, 2012</td><td style="text-align: center;;">9</td><td style="text-align: center;;">2</td><td style="text-align: center;;">3</td><td style="text-align: center;;">8</td><td style="text-align: right;background-color: #A6A6A6;;">
</td><td style="text-align: center;;">2</td><td style="text-align: center;;">3</td><td style="text-align: center;;">8</td><td style="text-align: center;;">9</td></tr><tr><td style="color: #161120;text-align: center;">3</td><td style=";">Sun. Apr 01, 2012</td><td style="text-align: center;;">5</td><td style="text-align: center;;">2</td><td style="text-align: center;;">3</td><td style="text-align: center;;">2</td><td style="text-align: right;background-color: #A6A6A6;;">
</td><td style="text-align: center;;">2</td><td style="text-align: center;;">2</td><td style="text-align: center;;">3</td><td style="text-align: center;;">5</td></tr><tr><td style="color: #161120;text-align: center;">4</td><td style=";">Sat. Mar 31, 2012</td><td style="text-align: center;;">1</td><td style="text-align: center;;">6</td><td style="text-align: center;;">0</td><td style="text-align: center;;">7</td><td style="text-align: right;background-color: #A6A6A6;;">
</td><td style="text-align: right;;">
</td><td style="text-align: right;;">
</td><td style="text-align: right;;">
</td><td style="text-align: right;;">
</td></tr><tr><td style="color: #161120;text-align: center;">5</td><td style=";">Fri. Mar 30, 2012</td><td style="text-align: center;;">9</td><td style="text-align: center;;">2</td><td style="text-align: center;;">2</td><td style="text-align: center;;">2</td><td style="text-align: right;background-color: #A6A6A6;;">
</td><td style="text-align: right;;">
</td><td style="text-align: right;;">
</td><td style="text-align: right;;">
</td><td style="text-align: right;;">
</td></tr><tr><td style="color: #161120;text-align: center;">6</td><td style=";">Thu. Mar 29, 2012</td><td style="text-align: center;;">7</td><td style="text-align: center;;">2</td><td style="text-align: center;;">0</td><td style="text-align: center;;">7</td><td style="text-align: right;background-color: #A6A6A6;;">
</td><td style="text-align: right;;">
</td><td style="text-align: right;;">
</td><td style="text-align: right;;">
</td><td style="text-align: right;;">
</td></tr><tr><td style="color: #161120;text-align: center;">7</td><td style=";">Wed. Mar 28, 2012</td><td style="text-align: center;;">9</td><td style="text-align: center;;">8</td><td style="text-align: center;;">0</td><td style="text-align: center;;">7</td><td style="text-align: right;background-color: #A6A6A6;;">
</td><td style="text-align: right;;">
</td><td style="text-align: right;;">
</td><td style="text-align: right;;">
</td><td style="text-align: right;;">
</td></tr><tr><td style="color: #161120;text-align: center;">8</td><td style=";">Tue. Mar 27, 2012</td><td style="text-align: center;;">1</td><td style="text-align: center;;">5</td><td style="text-align: center;;">5</td><td style="text-align: center;;">0</td><td style="text-align: right;background-color: #A6A6A6;;">
</td><td style="text-align: right;;">
</td><td style="text-align: right;;">
</td><td style="text-align: right;;">
</td><td style="text-align: right;;">
</td></tr><tr><td style="color: #161120;text-align: center;">9</td><td style=";">Mon. Mar 26, 2012</td><td style="text-align: center;;">0</td><td style="text-align: center;;">9</td><td style="text-align: center;;">5</td><td style="text-align: center;;">9</td><td style="text-align: right;background-color: #A6A6A6;;">
</td><td style="text-align: right;;">
</td><td style="text-align: right;;">
</td><td style="text-align: right;;">
</td><td style="text-align: right;;">
</td></tr></tbody></table>
Lottery_4_balls
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
You can use the SMALL function for that...

IN G2, put
=SMALL($B2:$E2,COLUMNS($A1:A1))
And fill right/down as far as needed


Excel Workbook
ABCDEFGHIJ
1DATEBall1Ball2Ball3Ball4NewBall1NewBall2NewBall3NewBall4
2Mon. Apr 02, 201292382389
3Sun. Apr 01, 201252322235
4Sat. Mar 31, 201216070167
5Fri. Mar 30, 201292222229
6Thu. Mar 29, 201272070277
7Wed. Mar 28, 201298070789
8Tue. Mar 27, 201215500155
9Mon. Mar 26, 201209590599
Sheet1
 
Upvote 0
This in G2 would do the same
Code:
=SMALL($B2:$E2,COLUMN(A$1))
Drag across to Column J, then Down as required.

However I'm intrigued as to what kind of lottery has duplicate numbers and zero balls ... :confused:
 
Upvote 0
This in G2 would do the same
Code:
=SMALL($B2:$E2,COLUMN(A$1))
Drag across to Column J, then Down as required.

However I'm intrigued as to what kind of lottery has duplicate numbers and zero balls ... :confused:

Column(S) is more robust against isertion of columns..

If you just use
COLUMN($A1), and insert a column to the left, then it changes to
COLUMN($B1)
And would then return 2 instead of 1

where COLUMNS($A1:A1) would change to
COLUMNS($B1:B1)
And would still return 1.
 
Upvote 0
@ jonmo1
Good point, but aren't you overthinking things a little?

I wouldn't put a pound on a lottery that had zero balls ... ;)
 
Last edited:
Upvote 0
Hi Jonmo1,
Yes, it works beautifully. Thank you.

So, just for my own understanding, I get the =SMALL($B2:$E2 part,
but I don't understand the COLUMNS($A1:A1)) part, or specifically, what it is referencing (for example, the first one references the "Date" row.

Mark
 
Upvote 0
=SMALL has two arguments:
  • Array Required. An array or range of numerical data for which you want to determine the k-th smallest value.
  • K Required. The position (from the smallest) in the array or range of data to return.
jonmo1's formulas use the COLUMNS function for the second argument. The COLUMNS function returns the number of columns in an array or reference.

In your first column (G), =COLUMNS($A1:A1) returns a value of 1 which returns the smallest number.
In your second column (H), =COLUMNS($A1:B1) returns a value of 2 which returns the second smallest number.
And so on through column (I) for the third smallest number and column (J) for the fourth smallest number.
 
Upvote 0
Hi Jonmo1,
Yes, it works beautifully. Thank you.

So, just for my own understanding, I get the =SMALL($B2:$E2 part,
but I don't understand the COLUMNS($A1:A1)) part, or specifically, what it is referencing (for example, the first one references the "Date" row.

Mark

Jeff explained it pretty well..

The COLUMNS part isn't referencing the CONTENTS of $A1:A1...
Just the Cells themselves, specifically the count of how many columns are in the range reference.
 
Upvote 0

Forum statistics

Threads
1,215,639
Messages
6,125,970
Members
449,276
Latest member
surendra75

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