Divide a list into Groups

S

SerpentineFire

I need divide a list of 500 lines into groups of 8 and assign a number or
name to each group
 
J

Joel

This requires a simple macro. Do you want a space inbetween each group. How
do you want to assign a number? Write the number in column A? Need a little
more details to get it right.
 
S

SerpentineFire

No space needed. I have 500 lines that i need evenly divided in to 8 groups.
So line 1-62 is assigned group 1 (or # 1) 63-124 group 2 and so on... The
group number would be in Column A. Hope this is enough Details
 
J

Joel

Sub number_groups()

Const NumLines = 500
Const NumGroups = 8

GroupSize = Int(NumLines / NumGroups)

GroupNum = 1
For Lines = 1 To NumLines
GroupNum = WorksheetFunction.RoundUp(Lines / GroupSize, 0)
Range("A" & Lines) = GroupNum
Next Lines

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top