Transpose Values VBA for week

mahmed1

Well-known Member
Joined
Mar 28, 2009
Messages
2,302
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi All,

I have a data set that is stored like this (I dont need total in output)

AreaDateMonTueWedThuFriSatSunTotal
Team 120-07-2014372032343524196
Team 127-07-204846364810216206
Team 220-07-203831421610103150
Team 227-07-2033151519314727187


How can i use VBA to transpose the information in a tabular format like below

AreaDateIncoming
Team 120/07/202014
Team 121/07/202037
Team 122/07/202020
Team 123/07/202032
Team 124/07/202034
Team 125/07/202035
Team 126/07/202024
Team 127/07/202048
Team 128/07/202046
Team 129/07/202036
Team 130/07/202048
Team 131/07/202010
Team 101/08/20202
Team 102/08/202016
Team220/07/202038
Team221/07/202031
Team222/07/202042
Team223/07/202016
Team224/07/202010
Team225/07/202010
Team226/07/20203
Team227/07/202033
Team228/07/202015
Team229/07/202015
Team230/07/202019
Team231/07/202031
Team201/08/202047
Team202/08/202027


My Sheet is called Data and the headings start from A1

Many Thanks
 
Yup you can do that. :)
Assuming the table starts in A1
you can use
VBA Code:
   With Sheets("Pastesheet").ListObjects("tblIncoming")
      .DataBodyRange.Delete
      .Parent.Range("A2").Resize(nr, 3).Value = Nary
   End With
 
Upvote 0

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
You're welcome & thanks for the feedback.
 
Upvote 0
Hi Again bud - ive been asked to split this data further by half hour period :( - is this something you can please help me with

So once the data is transposed by day split it like this and the value Stays the same for each interval from 00:00, 00:30,01:00...23:30

Eg..

Team Date Period Incoming
Team1 01/01/2020 00:00 48
Team1 01/01/2020 00:30 48.
Team1 01/01/2020 01:00 48.....
Team1 01/01/2020 23:30 48
Team2 01/01/2020 00:00 55
Team2 01/01/2020 00:30 55....
Team2 01/01/2020 23:30 55

so plan is to in the 3rd column have the half hour slot for whole day as part of the code and split like above .... thank you so much
 
Upvote 0
That is a totally different question, so needs a new thread. Thanks
 
Upvote 0
Ok thank you will create a new thread now

thank you
 
Upvote 0
I have tried to follow up the question in the other thread but not sure if ive been clear enough as its a follow up to add at the end of this code

again thank you
 
Upvote 0
Hi Fluff - i've tried your code - it worked fine until i added a couple of extra columns at the end of total (ID and Type)

So my source data header is like this

1594902924709.png


I still dont need Total but the output will be like these headers

1594902993907.png


This was my amended code

VBA Code:
Sub UpdateData()
   Dim Ary As Variant, Nary As Variant
   Dim r As Long, nr As Long, c As Long
   
   Ary = Sheets("TempData").Range("A1").CurrentRegion.Value2
   ReDim Nary(1 To UBound(Ary) * UBound(Ary, 2), 1 To 5)
   
   For r = 2 To UBound(Ary)
      For c = 3 To UBound(Ary, 2) - 1
         nr = nr + 1
         Nary(nr, 1) = Ary(r, 2) + c - 3
         Nary(nr, 2) = Ary(r, 1)
         Nary(nr, 3) = Ary(r, c)
         Nary(nr, 4) = Ary(r, 11)
         Nary(nr, 5) = Ary(r, 12)
      Next c
   Next r
   
    With Sheets("Forecast_Volumes").ListObjects("tbl_Forecast")
      .DataBodyRange.Delete
      .Parent.Range("A2").Resize(nr, 5).Value = Nary
    End With
    
End Sub
 

Attachments

  • 1594902970618.png
    1594902970618.png
    2.2 KB · Views: 1
Upvote 0
Can you post some new sample data.
 
Upvote 0

Forum statistics

Threads
1,216,106
Messages
6,128,863
Members
449,473
Latest member
soumyahalder4

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