Separate drawn numbers and remaining numbers

motilulla

Well-known Member
Joined
Feb 13, 2008
Messages
2,362
Office Version
  1. 2010
Hello,

Data column C:G, row3

Question is bit tricky I will try my best to explain it if any further query please let me know I will try again.
Separate drawn numbers and remaining numbers once cycle is completed restart again.

At initial stage 1 to 50 numbers were in pool
1st draw 13/02/2004 numbers drawn 16-29-32-36-41 I want drawn numbers to be placed separated by comma in J3 = 5 numbers & rest 50-5 = 45 numbers to be placed separated by comma in K3

2nd draw 20-02-2004 numbers drawn 7-13-39-47-50 I want drawn numbers to be placed separated by comma in J4 = 10 numbers & rest 45-5 = 40 numbers to be placed separated by comma in K4

3rd draw 27-02-2004 numbers drawn 14-18-19-31-37 I want drawn numbers to be placed separated by comma in J5 = 15 numbers & rest 40-5 = 35 numbers to be placed separated by comma in K5

4th draw 05-03-2004 numbers drawn 4-7-33-37-39 (3 values are duplicates 7,37 & 39) I want drawn numbers to be placed separated by comma in J6 = 15+2 =17 numbers & rest 35-3 = 33 numbers to be placed separated by comma in K5

Once cycle is completed and all 1 to 50 numbers are drawn restart again all 50 is completed in J68 and K68 is empty

Restart from beginning in J69 as shown in example below



Book1
ABCDEFGHIJK
1YearFECHAn1n2n3n4n5Drawn NumbersRemaining Numbers
2YearFECHAn1n2n3n4n5Drawn NumbersRemaining Numbers
3200413/02/2004162932364116,29,32,36,411,2,3,4,5,6,7,8,9,10,11,12,13,14,15,17,18,19,20,21,22,23,24,25,26,27,28,30,31,33,34,35,37,38,39,40,42,43,44,45,46,47,48,49,50
4200420/02/20047133947507,13,16,29,32,36,39,41,47,501,2,3,4,5,6,8,9,10,11,12,14,15,17,18,19,20,21,22,23,24,25,26,27,28,30,31,33,34,35,37,38,40,42,43,44,45,46,48,49
5200427/02/200414181931377,13,14,16,18,19,29,31,32,36,37,39,41,47,501,2,3,4,5,6,8,9,10,11,12,15,17,20,21,22,23,24,25,26,27,28,30,33,34,35,38,40,42,43,44,45,46,48,49
6200405/03/2004473337394,7,13,14,16,18,19,29,31,32,33,36,37,39,41,47,501,2,3,5,6,8,9,10,11,12,15,17,20,21,22,23,24,25,26,27,28,30,34,35,38,40,42,43,44,45,46,48,49
7200412/03/20041524284447
8200419/03/20043336374245
9200426/03/200434102343
10200402/04/2004412242736
11200409/04/200414101923
12200416/04/20041415283540
13200423/04/2004610214549
14200430/04/200456162327
15200407/05/20041516213638
16200414/05/200413213239
17200421/05/20041529373949
18200428/05/2004611354144
19200404/06/2004913344142
20200411/06/20042781047
21200418/06/2004223284043
22200425/06/2004321303435
23200402/07/2004423242834
24200409/07/200425121944
25200416/07/20042426313850
26200423/07/2004710273134
27200430/07/2004910193750
28200406/08/2004515243544
29200413/08/20042027414350
30200420/08/200469102735
31200427/08/2004111222844
32200403/09/2004812141534
33200410/09/2004525333638
34200417/09/20041518293941
35200424/09/20042126274448
36200401/10/20041220214548
37200408/10/2004110121648
38200415/10/20041421223743
39200422/10/200419232540
40200429/10/200418323538
41200405/11/2004619254249
42200412/11/2004411121332
43200419/11/2004118293437
44200426/11/200414243436
45200403/12/2004111154249
46200410/12/200413131643
47200417/12/20041519224649
48200424/12/200434272937
49200431/12/200478242547
50200507/01/2005323274750
51200514/01/2005611141929
52200521/01/20051012142426
53200528/01/2005721264345
54200504/02/200518113040
55200511/02/20051113253250
56200518/02/20052021263246
57200525/02/2005327304344
58200504/03/20051224323739
59200511/03/2005812234043
60200518/03/2005623394348
61200525/03/2005429333738
62200501/04/20052526414447
63200508/04/2005711253150
64200515/04/2005628313842
65200522/04/2005310132447
66200529/04/200539353942
67200506/05/2005712212644
68200513/05/200512173132401,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50
69200520/05/2005671328476,7,13,28,471,2,3,4,5,8,9,10,11,12,14,15,16,17,18,19,20,21,22,23,24,25,26,27,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,48,49,50
70200527/05/2005224314850
71200503/06/200538111750
72200510/06/200567323747
73200517/06/200548101821
74200524/06/200568141545
75200501/07/200545232528
Sheet1


Thanks In Advance
Using version 2000

Regards,
Moti
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Try this:


Code:
Dim dict As Object
Sub motiulla()
Dim i       As Long
Dim j       As Long
Dim k       As Long
Dim n       As Long
Dim ar      As Variant
Dim list    As Object
Dim oar     As Variant

Set list = CreateObject("system.collections.arraylist")
Set dict = CreateObject("scripting.dictionary")
lr = Cells(Rows.Count, "C").End(xlUp).Row

ReDim oar(1 To lr, 1 To 2)
Call filldict

k = 1
For i = 3 To lr
    ar = Range("C" & i & ":G" & i)
    
    For j = 1 To UBound(ar, 2)
        If Not list.contains(ar(1, j)) Then
            list.Add ar(1, j)
            dict.Remove ar(1, j)
        End If
    Next
    
    list.Sort
    dra = Join(list.toarray, ",")
    Rmn = Join(dict.keys(), ",")
    oar(k, 1) = dra: oar(k, 2) = Rmn
    k = k + 1
    If dict.Count = 0 Then
        Call filldict
        list.Clear
    End If
Next
Range("J3").Resize(lr, 2) = oar
End Sub
Sub filldict()
dict.RemoveAll
For n = 1 To 50
    dict.Item(n) = vbEmpty
Next
End Sub
 
Upvote 0
Like this perhaps. Results in columns N and O.
Code:
Sub moti2()

Const q As Long = 50
Dim a, b() As Boolean, u()
Dim i As Long, j As Long, n As Long
n = Cells(Rows.Count, "d").End(xlUp).Row
a = Range("D:H").Resize(n)
ReDim b(1 To q), u(1 To n, 1 To 2)

For i = 3 To n
    For j = 1 To 5
        If Not b(a(i, j)) Then b(a(i, j)) = True: c = c + 1
    Next j
    
    For j = 1 To q
        If b(j) Then u(i, 1) = u(i, 1) & "," & j Else u(i, 2) = u(i, 2) & "," & j
    Next j
    
    u(i, 1) = Mid(u(i, 1), 2)
    u(i, 2) = Mid(u(i, 2), 2)
    If c = q Then ReDim b(1 To q): c = 0
Next i

Range("N1").Resize(n, 2) = u
Range("N1").Resize(2, 2) = Array("Drawn Numbers", "Remaining Numbers")

End Sub
 
Upvote 0
Try this:
Code:
Dim dict As Object
Sub motiulla()
End Sub
Ombir, please can you check code stop at line below may be it is due to version I am using?
Code:
 Set list = CreateObject("system.collections.arraylist")

Thank you for your help

Regards,
Moti
 
Upvote 0
Hello,

Sorry for the inconvenience please require a modification to be analysed in detailed, could Drawn Numbers results can be separated in 50 cells from L3 to BI50 (Header L1:BI1 listed 1 To 50 Numbers) & Remaining Numbers can be separated in 50 cells from BK3 to DH50 (Header BK1:DH1 listed 1 To 50 Numbers)

Thank you

Regards,
Moti
 
Upvote 0
Hello,

L3 to BI50 (Header L1:BI1 listed 1 To 50 Numbers) & Remaining Numbers can be separated in 50 cells from
BK3 to DH50 (Header BK1:DH1 listed 1 To 50 Numbers)

Thank you

Regards,
Moti
Hello,

In post#6 I have typo error correct is L3:BI3 & BK3:DH3

Here also I want to clear Drawn Or Remaining number has to go in their header columns

For example first draw "drawn numbers 16,29,32,36,41" in range
L3:BI3, 16 has to go AA3, 29 in AN3, 32 in AQ3, 36 in AU3 & 41 in AZ3. And the rest remaining numbers 45 in range BK3:DH3 in their corresponding header columns

Thank you

Regards,
Moti
 
Last edited:
Upvote 0
Ombir, please can you check code stop at line below may be it is due to version I am using?
Code:
 Set list = CreateObject("system.collections.arraylist")

Thank you for your help

Regards,
Moti


Hi,


I don't have Excel 2000 to test so I'm afraid I can't help. May be you've to provide reference to library containing Array List object. I searched but couldn't able to find the exact library name for this Object.
 
Upvote 0
Hi,

I don't have Excel 2000 to test so I'm afraid I can't help. May be you've to provide reference to library containing Array List object. I searched but couldn't able to find the exact library name for this Object.
Hello Ombir,

I appreciate a lot you efforts I found 2 links I do not know weather these link have any information about Excel version 2000.
https://msdn.microsoft.com/en-us/library/system.collections.arraylist(v=vs.110).aspx
https://msdn.microsoft.com/en-us/library/system.collections.arraylist.contains(v=vs.110).aspx

kalak, code is working perfect with scenario post#1.

Please can you take a look what I am looking now instead results output in single column
Split in 50 columns Drawn Results in cells L3:BI17,
Split in 50 columns Remaining Numbers results in cells BK3:DH17

Drawn Results new example sheet


Book1
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARASATAUAVAWAXAYAZBABBBCBDBEBFBGBHBI
1YearFECHAn1n2n3n4n51234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
2YearFECHAn1n2n3n4n5n1n2n3n4n5n6n7n8n9n10n11n12n13n14n15n16n17n18n19n20n21n22n23n24n25n26n27n28n29n30n31n32n33n34n35n36n37n38n39n40n41n42n43n44n45n46n47n48n49n50
3200413/02/200416293236411629323641
4200420/02/2004713394750713162932394750
5200427/02/20041418193137714161819293132363739414750
6200405/03/20044733373947131416181929313233363739414750
7200412/03/20041524284447
8200419/03/20043336374245
9200426/03/200434102343
10200402/04/2004412242736
11200409/04/200414101923
12200416/04/20041415283540
13200423/04/2004610214549
14200430/04/200456162327
15200407/05/20041516213638
16200414/05/200413213239
17200421/05/20041529373949
Sheet1-3


Remaining Numbers new example sheet


Book1
BKBLBMBNBOBPBQBRBSBTBUBVBWBXBYBZCACBCCCDCECFCGCHCICJCKCLCMCNCOCPCQCRCSCTCUCVCWCXCYCZDADBDCDDDEDFDGDH
11234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
2n1n2n3n4n5n6n7n8n9n10n11n12n13n14n15n16n17n18n19n20n21n22n23n24n25n26n27n28n29n30n31n32n33n34n35n36n37n38n39n40n41n42n43n44n45n46n47n48n49n50
3123456789101112131415171819202122232425262728303133343537383940424344454647484950
41234568910111214151718192021222324252627283031333435363738404142434445464849
51234568910111213151720212223242526272830333435384042434445464849
612356891011121517202122232425262728303435384042434445464849
7
8
9
10
11
12
13
14
15
16
17
Sheet1-3


Thank you very much

Regards,
Moti
 
Upvote 0
Code:
Sub moti3()

Const q As Long = 50
Dim a, b() As Boolean, u(), v()
Dim i As Long, j As Long, n As Long, x As Long, y As Long
n = Cells(Rows.Count, "d").End(xlUp).Row
a = Range("D:H").Resize(n)
ReDim b(1 To q), u(1 To n, 1 To q), v(1 To n, 1 To q)

For i = 3 To n
    For j = 1 To 5
        If Not b(a(i, j)) Then b(a(i, j)) = True: c = c + 1
    Next j
    For j = 1 To q
        If b(j) Then u(i, j) = j Else v(i, j) = j
    Next j
     If c = q Then ReDim b(1 To q): c = 0
Next i

Range("L1").Resize(n, q) = u
Range("L1").Resize(n, q).Columns.AutoFit
Range("BK1").Resize(n, q) = v
Range("BK1").Resize(n, q).Columns.AutoFit

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,583
Members
449,089
Latest member
Motoracer88

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