Distribute 35000 Rows equally into 6 different excel sheets

rajkumarthakur1

New Member
Joined
Oct 3, 2005
Messages
32
Hi XL Gods,

I am stuck with this....I have a set of 35000 records which i want to distribute equally between 6 user..ie distribute 35000 records in 6 equal sheets....I am using Autofilter-->Top10 items and selecting the percentage required to distribute...but unable to do so......Please people help me I am stuck with this....



Can any1 please help me
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
35,000 records / 6 sheets = 5,833.33 records per sheet so things will not come out EXACTLY equal but it is a simple matter to break up one sheet of 35,000 into 6 sheets of 5,833 using cut and paste or Copy Sheet.
 
Upvote 0
Hi,

Try,

Code:
Sub kTest()
    Dim a, w(), i As Long, n As Long, h As Long, c  As Byte
    a = Sheets("Sheet1").[a1].CurrentRegion.Value
    h = Int((UBound(a, 1) + 1) / 6) + 1
    ReDim w(1 To h, 1 To UBound(a, 2))
    n = 1
    For i = 1 To UBound(a, 1)
        For c = 1 To UBound(a, 2): w(n, c) = a(i, c): Next
        If n = h Then
            Sheets.Add after:=Sheets(Sheets.Count)
            ActiveSheet.[a1].Resize(h, UBound(a, 2)) = w: n = 0
        End If: n = n + 1
    Next
    Sheets.Add after:=Sheets(Sheets.Count)
    ActiveSheet.[a1].Resize(n - 1, UBound(a, 2)) = w
End Sub

HTH
 
Upvote 0
a = Sheets("Sheet1").[a1].CurrentRegion.Value

HI Krishnakumar, just wondering if you could explain me what does [a1] mean...I was trying to figure it out, but I can´t :cry:
Oh... in that expression I quoted, you are setting "a" as a range?
Thanks!!!!!!
 
Upvote 0
Hi XLgods,

I needed to prevent the copy paste activity on a particular excel sheet....Please can any one help me...i need it urgent
 
Upvote 0
Hi,

Sub kTest()
Dim a, w(), i As Long, n As Long, h As Long, c As Byte
a = Sheets("Sheet1").[a1].CurrentRegion.Value
h = Int((UBound(a, 1) + 1) / 6) + 1
ReDim w(1 To h, 1 To UBound(a, 2))
n = 1
For i = 1 To UBound(a, 1)
For c = 1 To UBound(a, 2): w(n, c) = a(i, c): Next
If n = h Then
Sheets.Add after:=Sheets(Sheets.Count)
ActiveSheet.[a1].Resize(h, UBound(a, 2)) = w: n = 0
End If: n = n + 1
Next
Sheets.Add after:=Sheets(Sheets.Count)
ActiveSheet.[a1].Resize(n - 1, UBound(a, 2)) = w
End Sub

The Above code some times works fine but some times dose not and give the following error

Run-time error 1004
Application-defined or object-define error

when I click on debug it highlights the following

ActiveSheet.[a1].Resize(h, UBound(a, 2)) = w


Kindly help me out what is the problem.

Regards,
Shafiq
 
Upvote 0

Forum statistics

Threads
1,214,988
Messages
6,122,620
Members
449,092
Latest member
amyap

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