Splitting Out Rows

StrangeLuck

New Member
Joined
Mar 25, 2002
Messages
15
Let's say I have a large group of data like this:

12:00 AM 4
12:00 AM 7
12:00 AM 34
12:00 AM 3
12:30 AM 31
12:30 AM 4
12:30 AM 4
12:30 AM 7

with multiple values for each time. How can i get the data to look like this:

12:00 AM 4 12:00 AM 7 12:00 AM 34, etc?

In other words, I want the large column of data split into eight columns whereby columns 1,3,5,7 would be the dates and 2,4,6,8 would be the data. Any ideas?
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
12:00 AM 4
12:00 AM 7
12:00 AM 34
12:00 AM 3
12:30 AM 31
12:30 AM 4
12:30 AM 4
12:30 AM 7



12:00 AM 4 12:00 AM 7 12:00 AM 34, etc?

In other words, I want the large column of data split into eight columns whereby columns 1,3,5,7 would be the dates and 2,4,6,8 would be the data.

>> Sorry cant see a dte in your example but try right and left to pick off the cells you require. combine with FIND BLANK and from left will return as you want.. OK different formula in each cell but once done can DRAG..

any ggod.
 
Upvote 0
Hi StrangeLuck,

Here is a simple macro (with a helper procedure) that does this. I assumed that the data you showed in your example was all in one column, not two. This code is based on the data starting in column A, row 1, but hopefully it is obvious how to modify it to work with any other column or starting row.

Sub RowsToColumns()
Dim iRow As Long
Dim LeftPart As String
Dim RightPart As String
For iRow = 1 To [a65536].End(xlUp).Row
ParseString Cells(iRow, 1), LeftPart, RightPart
Cells(iRow, 1) = ""
Cells(1, 2 * (iRow - 1) + 1) = LeftPart
Cells(1, 2 * iRow) = RightPart
Next iRow
End Sub

Sub ParseString(StrIn As String, Token1 As String, Token2 As String)
'Parses string, separating values using last blank separator in
'string to divide the two tokens
Dim Schr As Integer 'the position of the last blank
Dim iCh As Integer

For iCh = Len(StrIn) To 4 Step -1
If Mid(StrIn, iCh, 1) = " " Then
'token separating blank found at character iCh
Token1 = Left(StrIn, iCh - 1)
Token2 = Mid(StrIn, iCh + 1)
Exit Sub
End If
Next iCh
'No token2 found
Token1 = StrIn
Token2 = ""
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,565
Messages
6,114,338
Members
448,569
Latest member
Honeymonster123

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