Need a formula can count distance between groups.

motilulla

Well-known Member
Joined
Feb 13, 2008
Messages
2,415
Office Version
  1. 2010
Using Excel 2010

Hello,

I need a formula which can count a distance between groups. IN the column “C” I have some lottery numbers lottery is divided in the 4 groups of 5-numbers

I need a formula…
In cells E7:F12 for Group1
In cells H7:I12 for Group2
In cells K7:L12 for Group3
In cells N7:O12 for Group4

Now for example…in the cell C7 first number come up this is 3 and placed under the group1 in the cell S7…

Cell E7:F7 I need a formula which tells me if next coming up number (adding or subtracting from 3) will be -2 or +2 will be remain in the group1

Cell H7:I7 I need a formula which tells me if next coming up number (adding or subtracting from 3) will be 3 or 7 will be remain in the group2

Cell K7:L7 I need a formula which tells me if next coming up number (adding or subtracting from 3) will be 8 or 12 will be remain in the group3

Cell N7:O7 I need a formula which tells me if next coming up number (adding or subtracting from 3) will be 13 or 17 will be remain in the group4

This is how I want to count the distance of each number between groups same as for next number 13, 8, 19, 1 and 14 hope I have explained if any question please I will try to explain it again.

Excel Question.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKAL
1Group1Group2Group3Group4
2116611111616
3ToToToToToToToTo
455101015152020
5LotteryMoveMoveMoveMoveGroup1Group2Group3Group4
6NumberMinMaxMinMaxMinMaxMinMax1234567891011121314151617181920
73-223781213173
812-7-11-2-6-134812
98-3-7-22378128
1019-14-18-9-13-4-8-3119
1110459101415191
1214-9-13-4-8-312614
13
14
15
16
17
18
19
20
Sheet4


Thank you all.

Regards,
Moti
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
@motilulla I think this might do it?
Formulas in E7 & F7 can be pulled down. Then E7:F12 can be Copy Pasted to the other three ranges.
If my understanding of Max and Min is that Min is the shorter distance then I think you have your example results the wrong way round in K12:L12 and N10:O10?

Book1
ABCDEFGHIJKLMNOP
1Group1Group2Group3Group4
2116611111616
3ToToToToToToToTo
455101015152020
5LotteryMoveMoveMoveMove
6NumberMinMaxMinMaxMinMaxMinMax
73-22378121317
812-7-11-2-6-1348
98-3-7-2237812
1019-14-18-9-13-4-81-3
111045910141519
1214-9-13-4-81-326
13
Sheet1
Cell Formulas
RangeFormula
E7:E12,N7:N12,K7:K12,H7:H12E7=IF(E$4-$C7=2,$C7-E$4,IF(ABS(E$2-$C7)<ABS(E$4-$C7),E$2-$C7,E$4-$C7))
F7:F12,O7:O12,L7:L12,I7:I12F7=IF(ABS(E$2-$C7)>ABS(E$4-$C7),E$2-$C7,E$4-$C7)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
E7:O12Expression=E7>=0textNO
E7:O12Expression=E7<0textNO


Hope that helps.
 
Upvote 0
Solution
@motilulla I think this might do it?
Formulas in E7 & F7 can be pulled down. Then E7:F12 can be Copy Pasted to the other three ranges.
If my understanding of Max and Min is that Min is the shorter distance then I think you have your example results the wrong way round in K12:L12 and N10:O10?

Book1
ABCDEFGHIJKLMNOP
1Group1Group2Group3Group4
2116611111616
3ToToToToToToToTo
455101015152020
5LotteryMoveMoveMoveMove
6NumberMinMaxMinMaxMinMaxMinMax
73-22378121317
812-7-11-2-6-1348
98-3-7-2237812
1019-14-18-9-13-4-81-3
111045910141519
1214-9-13-4-81-326
13
Sheet1
Cell Formulas
RangeFormula
E7:E12,N7:N12,K7:K12,H7:H12E7=IF(E$4-$C7=2,$C7-E$4,IF(ABS(E$2-$C7)<ABS(E$4-$C7),E$2-$C7,E$4-$C7))
F7:F12,O7:O12,L7:L12,I7:I12F7=IF(ABS(E$2-$C7)>ABS(E$4-$C7),E$2-$C7,E$4-$C7)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
E7:O12Expression=E7>=0textNO
E7:O12Expression=E7<0textNO


Hope that helps.
Snakehips, just applied the formulas its result are as I needed amazing! 👍

Thank you for your kind help it has been very valuable for me. 🙌

Good Luck

Kind Regards,
Moti :)
 
Upvote 0

Forum statistics

Threads
1,221,841
Messages
6,162,331
Members
451,759
Latest member
damav78

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