Divide Every 40 Numbers into Columns wise

Mohanmoni

New Member
Joined
Mar 9, 2016
Messages
15
Hi,

I am looking for formula that divides in data or numbers into 40 rows and paste in new column.

Example:
============
Column A
15248
2113547
2665478
265475
2546981
.
.
.
Etc

Like above example in Column"A" I have a list of numbers upto 200,000 (2 Lakh). Now I need this to divide after every 40 rows and paste in new column.

Example:
=============
Column A
15248
2113547
2665478
265475
2546981
.
.
First 40 numbers in Column "A" and Next 40 numbers in Column "B" and Next 40 numbers in Column"C"..........

Please suggest have any code for this.

Thanks You,
Mohan
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Code:
Option Explicit


Sub mohan()
    Dim i As Long, lc As Long, lr As Long
    lr = Range("A" & Rows.Count).End(xlUp).Row
    lc = 1
    For i = 41 To lr Step 40
        Range("A" & i & ":A" & i + 39).Cut Cells(1, lc + 1)
        lc = lc + 1
    Next i
End Sub
 
Upvote 0
I am looking for formula that divides in data or numbers into 40 rows and paste in new column.

Hi, here is a formula you can use; assumes you data in column A starts on row 2 and your results start in B2 - the formula can be copied down 40 rows and across as far as is required.

=INDEX($A$2:$A$200000,ROWS(B$2:B2)+(40*(COLUMNS($B2:B2)-1)))
 
Upvote 0
This should be quicker :
Code:
Sub FortyRows()
Dim lr#, sRay, dRay, r#
lr = Cells(Rows.Count, "A").End(xlUp).Row
sRay = Range("A1:A" & lr)
ReDim dRay(1 To 40, 1 To Int(lr / 40) + 1)
For r = 0 To lr - 1
  dRay(1 + (r Mod 40), 1 + Int(r / 40)) = sRay(r + 1, 1)
Next
Application.ScreenUpdating = False
[A1].Resize(40, UBound(dRay, 2)) = dRay
Range("A41:A" & lr).ClearContents
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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