split 1 column into multiple columns

breilly00

Board Regular
Joined
Sep 15, 2008
Messages
53
Office Version
  1. 365
Platform
  1. Windows
How can I to split data in WS Sheet Column 'D' into Columns 'C' thru last column
and place it under the right date. For example the Template sheet would have all the
team schedules under the date they play, the court they play on and the time.

A snippet of my macro thus far is shown at the end. It creates the data in the template sheet as shown in the example. But, I am lost on an approach to move the team data from the WS sheet under the matching date column along with getting the team data in the correct time and court place.





WS Sheet example looks like this
Col A Col B Col C Col D
DateTimeCourtsTeams
05/07/201910:00 AM11 v 9
05/07/201910:00 AM23 v 5
05/07/201910:00 AM48 v 10
05/07/201910:00 AM57 v 6
05/07/201910:00 AM611 v 4
05/14/201910:00 AM17 v 5
05/14/201910:00 AM26 v 10
05/14/201910:00 AM32 v 9
05/14/201910:00 AM48 v 4
05/14/201910:00 AM51 v 11

<colgroup><col><col><col span="2"></colgroup><tbody>
</tbody>

Template sheet example looks like this
Col A Col B Col C Col D Col E
05/07/2019 05/14/2019 05/21/2019
Time Court
10:00 1
2
3
4
5
6
7:00 1
2
3
4
5
6

<colgroup><col><col><col span="3"></colgroup><tbody>
</tbody>






Sub Mrexcel()


Dim cl As Range
Dim s1 As Integer
Dim s2 As Integer
Dim s3 As Integer
Dim s4 As Integer

'Copy unique dates from WS Sheet to Template sheet & convert them to rows
Sheets("WS").Activate
With CreateObject("scripting.dictionary")
For Each cl In Range("A2", Range("A" & Rows.Count).End(xlUp))
.Item(cl.Value) = Empty
Next cl
Sheets("Template").Range("c3").Resize(, .Count).Value2 = .keys
End With

'Move Date & Time From WS Sheet to Template Sheet
s2 = 5
s4 = 5
For s1 = 1 To NumofTimes
Sheets("template").Range("A" & s2) = Sheets("WS").Range("F" & s1 + 1)
For s3 = 1 To NumofCourts
Sheets("template").Range("B" & s4) = Sheets("WS").Range("G" & s3 + 1)
s4 = s4 + 1
Next s3
s2 = 5 + NumofCourts
Next s1






End Sub
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
something like this?

DateTimeCourtsTeamsTimeCourts07/05/201914/05/2019
07/05/2019​
10:00:00​
1​
1 v 9
10:00:00​
1​
1 v 97 v 5
07/05/2019​
10:00:00​
2​
3 v 5
10:00:00​
2​
3 v 56 v 10
07/05/2019​
10:00:00​
4​
8 v 10
10:00:00​
3​
2 v 9
07/05/2019​
10:00:00​
5​
7 v 6
10:00:00​
4​
8 v 108 v 4
07/05/2019​
10:00:00​
6​
11 v 4
10:00:00​
5​
7 v 61 v 11
14/05/2019​
10:00:00​
1​
7 v 5
10:00:00​
6​
11 v 4
14/05/2019​
10:00:00​
2​
6 v 10
14/05/2019​
10:00:00​
3​
2 v 9
14/05/2019​
10:00:00​
4​
8 v 4
14/05/2019​
10:00:00​
5​
1 v 11

btw. your result example has nothing to do with your source example
 
Upvote 0
something like this?

[COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Date[/COLOR][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Time[/COLOR][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Courts[/COLOR][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Teams[/COLOR][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Time[/COLOR][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Courts[/COLOR][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]07/05/2019[/COLOR][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]14/05/2019[/COLOR]
07/05/2019​
10:00:00​
1​
1 v 9
10:00:00​
1​
1 v 97 v 5
07/05/2019​
10:00:00​
2​
3 v 5
10:00:00​
2​
3 v 56 v 10
07/05/2019​
10:00:00​
4​
8 v 10
10:00:00​
3​
2 v 9
07/05/2019​
10:00:00​
5​
7 v 6
10:00:00​
4​
8 v 108 v 4
07/05/2019​
10:00:00​
6​
11 v 4
10:00:00​
5​
7 v 61 v 11
14/05/2019​
10:00:00​
1​
7 v 5
10:00:00​
6​
11 v 4
14/05/2019​
10:00:00​
2​
6 v 10
14/05/2019​
10:00:00​
3​
2 v 9
14/05/2019​
10:00:00​
4​
8 v 4
14/05/2019​
10:00:00​
5​
1 v 11

<tbody>
</tbody>


btw. your result example has nothing to do with your source example

This what I am trying to get to

Spring and Fall Bocce League
05/07/201905/14/201905/21/201905/28/201906/04/201906/11/201906/13/201906/18/201906/20/201906/25/201906/27/2019
TimeCourt
10:00 AM1
2
3
4
5
6
7:00 PM1
2
3
4
5
6

<colgroup><col><col><col span="11"></colgroup><tbody>
</tbody>
 
Upvote 0
first: don't quote whole post!

second: use Power Query (Get&Transform)

Code:
[SIZE=1]// Table1
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Type = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Time", type time}, {"Courts", Int64.Type}, {"Teams", type text}}),
    Pivot = Table.Pivot(Table.TransformColumnTypes(Type, {{"Date", type text}}, "en-GB"), List.Distinct(Table.TransformColumnTypes(Type, {{"Date", type text}}, "en-GB")[Date]), "Date", "Teams")
in
    Pivot[/SIZE]
 
Upvote 0
here is answer on your PM's question (PM is limited by the number of characters)

sourceresult
DateTimeCourtsTeamsTimeCourts07/05/201914/05/201921/05/201928/05/201904/06/2019
07/05/2019​
10:00:00​
1​
1 v 9
07:00:00​
3​
2 v 8
07/05/2019​
10:00:00​
2​
3 v 5
10:00:00​
1​
1 v 97 v 56 v 84 v 10
07/05/2019​
10:00:00​
4​
8 v 10
10:00:00​
2​
3 v 56 v 108 v 7
07/05/2019​
10:00:00​
5​
7 v 6
10:00:00​
3​
2 v 95 v 46 v 1
07/05/2019​
10:00:00​
6​
11 v 4
10:00:00​
4​
8 v 108 v 49 v 11
14/05/2019​
10:00:00​
1​
7 v 5
10:00:00​
5​
7 v 61 v 1110 v 29 v 5
14/05/2019​
10:00:00​
2​
6 v 10
10:00:00​
6​
11 v 43 v 12 v 11
14/05/2019​
10:00:00​
3​
2 v 9
19:00:00​
2​
1 v 7
14/05/2019​
10:00:00​
4​
8 v 4
19:00:00​
4​
6 v 3
14/05/2019​
10:00:00​
5​
1 v 11
19:00:00​
5​
4 v 9
21/05/2019​
10:00:00​
1​
6 v 8
19:00:00​
6​
10 v 5
21/05/2019​
10:00:00​
3​
5 v 4
21/05/2019​
10:00:00​
4​
9 v 11
21/05/2019​
10:00:00​
5​
10 v 2
21/05/2019​
10:00:00​
6​
3 v 1
28/05/2019​
10:00:00​
1​
4 v 10
28/05/2019​
10:00:00​
2​
8 v 7
28/05/2019​
10:00:00​
3​
6 v 1
28/05/2019​
10:00:00​
5​
9 v 5
28/05/2019​
10:00:00​
6​
2 v 11
04/06/2019​
19:00:00​
2​
1 v 7
04/06/2019​
07:00:00​
3​
2 v 8
04/06/2019​
19:00:00​
4​
6 v 3
04/06/2019​
19:00:00​
5​
4 v 9
04/06/2019​
19:00:00​
6​
10 v 5

M-code is exactly the same as in previous post, nothing changed, just paste data into blue table and use Refresh or Ctrl+Alt+F5

is that what you want to achieve?

and of course it would be good to learn more about Power Query :)
 
Last edited:
Upvote 0
TY soooo much Sandy (the devil). I need to spend some time with power query so I can understand the solution you gave. That is more than I hoped for. Thank You Again
Subject is closed.
 
Upvote 0

Forum statistics

Threads
1,214,416
Messages
6,119,386
Members
448,891
Latest member
tpierce

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