Help to extract data in certain format

Paul at GTS

Board Regular
Joined
May 17, 2004
Messages
56
Office Version
  1. 365
Platform
  1. Windows
Hi Guys can you help me ?

I have data on a worksheet as below

Product Date1 Date2 Date3
Apple 2 4 0
Banana 1 3 4


I need to get the data in the form, I have around 11000 rows. Using Excel from Office 365 Version 1711 Build 8730.2175

Apple Date1 2
Apple Date2 4
Apple Date3 0
Banana Date1 1
Banana Date2 3
Banana Date3 4

Thanks
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
How about
Code:
Sub CopyTranspose()

   Dim Hdrs As Variant
   Dim Cl As Range
   Dim SrcWs As Worksheet
   Dim DestWs As Worksheet
   
   Set SrcWs = Sheets("[COLOR=#ff0000]Data[/COLOR]")
   Set DestWs = Sheets("[COLOR=#ff0000]Sheet3[/COLOR]")
   
   Hdrs = Application.Transpose(SrcWs.Range("B1", SrcWs.Cells(1, Columns.Count).End(xlToLeft)))
   For Each Cl In SrcWs.Range("A2", SrcWs.Range("A" & Rows.Count).End(xlUp))
      With DestWs.Range("A" & Rows.Count).End(xlUp).Offset(1).Resize(UBound(Hdrs, 1))
         .Value = Cl.Value
         .Offset(, 1).Value = Hdrs
         .Offset(, 2).Value = Application.Transpose(Cl.Offset(, 1).Resize(, UBound(Hdrs, 1)).Value)
      End With
   Next Cl
End Sub
Change sheet names in red to suit
 
Upvote 0

Forum statistics

Threads
1,215,516
Messages
6,125,286
Members
449,218
Latest member
Excel Master

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