Splitting Row of 45 cells into 3 rows of 15 cells

AegonFlow

New Member
Joined
Apr 29, 2020
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi all

I have a data set that resembles something similar to this:

ID
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
2 ………………...………………………………………......……………………………………......……………...………...…………………………………..
3 ………………………………………………………………………………………………………………………………...…………………………………...
.
.
.
60 ……………………………………………………………………………………………………………...……………………………………………………….

I have 60 participants and for each one they have 45 different data values. Each of the values in the row in in a separate column. I am trying to re order this so as opposed to one long row of 45 columns of data points, I split it into 3 Rows of 15 data points resembling this format:

ID
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
2
2
2
3
3
3
.
.
.
.
60

So effectively I want to split the row at the 15th column twice to give me three rows. I have found a syntax that was attempting a similar issue and tried to use this, however although it splits my value at each 15th one it inserts the new row only in the first column not into 15 separate ones. The syntax is as follows:



Excel Code.PNG


Could anyone please offer some advice to how to either change this code to output into 15 separate columns not just first column or offer advice on an alternative method/code to get this results.

Any guidance would be wholly appreciated

Cheers

AegonFlow
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Assuming that your ID is in column A, and the data to split start in column B, and the data starts on row 1, try this code:
VBA Code:
Sub MyDataSplitter()

    Dim r As Long
   
    Application.ScreenUpdating = False
   
'   Set starting row
    r = 1

'   Loop through all rows
    Do
'       Check current row, and if blank, exit loop
        If Cells(r, "A") = "" Then Exit Do

'       Insert two blank lines under current row
        Rows(r + 1 & ":" & r + 2).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
'       Copy column A down
        Range(Cells(r + 1, "A"), Cells(r + 2, "A")).Value = Cells(r, "A").Value
'       Cut data from columns 17:31 to next row
        Range(Cells(r, 17), Cells(r, 31)).Cut Cells(r + 1, 2)
'       Cut data from column 32:46 to next row
        Range(Cells(r, 32), Cells(r, 46)).Cut Cells(r + 2, 2)
'       Add three to r to move down to next row to split
        r = r + 3
    Loop

    Application.ScreenUpdating = True
   
    MsgBox "Macro complete!", vbOKOnly
   
End Sub
 
Upvote 0
That has worked perfectly! Thankyou so much for your help Joe4, much appreciated!
 
Upvote 0
You are welcome.
Glad I was able to help!
:)
 
Upvote 0

Forum statistics

Threads
1,214,975
Messages
6,122,538
Members
449,088
Latest member
RandomExceller01

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