Change to list format

Dundee Lad

Active Member
Joined
Sep 6, 2003
Messages
311
Hi folks can you please help. I have searched the board but have not founf the answer i need. I have a workbook (sample data below)
Book1
ABCDEFG
1UINNAME22/03/200629/03/200605/04/200612/04/200619/04/2006
23WSEDRSAQ331
32WDFRTWSA112313
Sheet1

and I need to get it into the format below.(there are on average 3000 rows with 5 columns)
Book1
ABCD
1UINNAMEWEEKENDINGHOURS
23WSEDRSAQ22/03/20063
33WSEDRSAQ05/04/20063
43WSEDRSAQ19/04/20061
52WDFRTWSA29/03/200611
62WDFRTWSA05/04/200623
72WDFRTWSA12/04/20061
82WDFRTWSA19/04/20063
Sheet2
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

acw

MrExcel MVP
Joined
Feb 13, 2004
Messages
4,814
Hi

Try this.

Code:
Sub aaa()
  Dim OutSH As Worksheet
  Set OutSH = Sheets("Sheet2")
  Sheets("sheet1").Select
  OutSH.Range("a1:d1").Value = Array("UIN", "NAME", "WEEK ENDING", "HOURS")
  For i = 2 To Cells(Rows.Count, 1).End(xlUp).Row
    For j = 3 To Cells(1, Columns.Count).End(xlToLeft).Column
      If Not IsEmpty(Cells(i, j)) Then
        nextrow = OutSH.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
        OutSH.Cells(nextrow, 1).Value = Cells(i, 1)
        OutSH.Cells(nextrow, 2).Value = Cells(i, 2)
        OutSH.Cells(nextrow, 3).Value = Cells(1, j)
        OutSH.Cells(nextrow, 4).Value = Cells(i, j)
      End If
    Next j
  Next i
End Sub


Tony
 

Forum statistics

Threads
1,141,757
Messages
5,708,336
Members
421,566
Latest member
7Nabisco

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
Top