Column division

SGlobal

New Member
Joined
May 10, 2011
Messages
7
Hello,

I need help creating macro that selects a column, counts all the cells with in that column that have a value, then divides the range in to three blocks, evenly. Once divided, the first block (essentially the top block) stays in the same column, the second block (middle block) moves to the next column, and the third block (bottom block) moves to the third column. Can this be done?

so lets say I have a column, Column A with values in 30 cells from A1:A30. The macro should start at the top of the column count each cell that has a value and movedown until it hits an empty cell. In this case A31. After that it should take that count which should be 30 for this problem and divide by 3. Then it should leave the first 10 cells in the same column, take the next 10 cells and move to the next column, and the next 10 cells to the next column. If there were 60 cells it would leave the first 20 in the same column, move the next 20 to the second col, the next 20 to the third.

The number of cells will vary time to time. It may have 35 cells or it may have 60.

If anyone can help with this, it would be really helpful! Thanks!
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
try this

Code:
Sub SplitColumn()
Dim LR As Long
LR = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
SCol = Int(LR / 3)
Range(Cells(LR, 1), Cells(LR - SCol, 1)).Cut
ActiveSheet.Paste Range("C2")
LR = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
Range(Cells(LR, 1), Cells(LR - SCol, 1)).Cut
ActiveSheet.Paste Range("B2")
MsgBox "Done"
End Sub
 
Upvote 0
Hey, thanks for the respond. It needs a little tweaking but it works. I can tune the code a bit. Thanks alot! Really appreciate it! :)
 
Upvote 0

Forum statistics

Threads
1,224,607
Messages
6,179,871
Members
452,948
Latest member
UsmanAli786

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