Extract desire groups copy and paste them into another locations

motilulla

Well-known Member
Joined
Feb 13, 2008
Messages
2,422
Office Version
  1. 2010
Hello,</SPAN></SPAN>

Sheet1 I got lottery results in the cells D6:J3500, cells C6:C3500 I have assigned the numbers 1 to 356 each group has 9 rows rest of the rows are empty at movement.</SPAN></SPAN>

In the area D1:J3 where I want to put the group number, which I want to extract it, can be 1 to 21 and copy past that groups in the columns M:T as shown example in the below this would be in the same "Sheet1", also if possible may I request one more VBA that can copy paste groups in to "Sheet2" in the columns C:J please. </SPAN></SPAN>


Book1
ABCDEFGHIJKLMNOPQRST
1147
2
3
4
5Grn1n2n3n4n5*1*2Grn1n2n3n4n5*1*2
613610639316101361063931610
7135332640538135332640538
81210304411812103044118
91433819104611114338191046111
10123038434672123038434672
1112710304712981271030471298
1211540244838291154024483829
131293223151712932231517
141362110696213621106962
15246322734148443849626106
162961328374549152238102
172314928203524133237144817
1823225010376104271444151172
19232131439303943243263417210
20242322325371114104217323125
212135053315911442528543611
222377281341110423348243837
2329234016141544548403432101
243914238171726341337210
25326431214096721114132118
263710544341027243719283663
2731449211924511726452473795
2831549122642587134910453112
293433612421985740265012142
3034251936131172746382826
313232524916697191624373527
32331940955271943441245105
33443849626106
3449152238102
354133237144817
364271444151172
3743243263417210
384104217323125
39442528543611
40423348243837
4144548403432101
425402262749105
4353128421571011
4453227393615310
45541930144549
465371734162396
475462713432548
48563026481267
495731392333610
505264919453525
516213542144379
5261350423934119
5364311827784
54632351749551
5561119392827310
566433732264954
576115013402101
58638291048143
59612188443384
60726341337210
61721114132118
627243719283663
63726452473795
647134910453112
65740265012142
6672746382826
677191624373527
6871943441245105
698155036228112
70834374626248
7182265253475
72823145372384
7384893028178
748294213163568
758504016328211
7684512342430710
77828411171513
Sheet1


Thank you all</SPAN></SPAN>

Excel 2000</SPAN></SPAN>
Regards,</SPAN>
Moti</SPAN>
 
Code:
Dim cel As Range, rw%, c%, x%
[C5:J5].Copy [M5]
[C5:J5].Copy Sheets("Sheet2").[C5]
[M6:T3209].ClearContents
[M6:M3209].Interior.Pattern = xlNone
Sheets("Sheet2").[C6:J3209].ClearContents
Sheets("Sheet2").[C6:C3209].Interior.Pattern = xlNone
If WorksheetFunction.CountA([D1:J3]) = 0 Then Exit Sub
On Error Resume Next
For rw = 1 To 3
    For Each cel In Cells(rw, "D").Resize(, 7).SpecialCells(xlCellTypeConstants)
        With [C5:C3209].Find(cel, LookAt:=xlWhole).Resize(9, 8)
            .Copy Cells(Rows.Count, "M").End(3)(2)
            .Copy Sheets("Sheet2").Cells(Rows.Count, "C").End(3)(2)
        End With
    Next
Next
For c = 6 To Cells(Rows.Count, "M").End(3).Row Step 9
    If x = 0 Then
        Cells(c, "M").Resize(9).Interior.ColorIndex = 6
        Sheets("Sheet2").Cells(c, "C").Resize(9).Interior.ColorIndex = 6
        x = 1
    Else
        Cells(c, "M").Resize(9).Interior.ColorIndex = 38
        Sheets("Sheet2").Cells(c, "C").Resize(9).Interior.ColorIndex = 38
        x = 0
    End If
Next
On Error GoTo 0
Wow footoo, this is very good idea now it is looking clearer, separately group wise. Thanks a lot for your time you spent to solve full query in a nice way.</SPAN></SPAN>

Have a good day
</SPAN></SPAN>

Kind Regards,
</SPAN></SPAN>
Moti :-D
</SPAN></SPAN>
 
Upvote 0

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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