I have a table that looks like the results of a pivot table.
It has employees down the rows and the classes they took as columns. There is a date of the class to indicate the employee took that particular class. How can I get this into a "database" structure of:
employee, class code, class date.?
Is there a "unpivot"?
Last edited by jartzh; 03-12-2010 at 12:27 PM.
Is your table a pivot table, or is it just a table of data?
It will help if you can post example workbook.
Here is a sample of the problem: its not the result of a pivot table. It just looks like it.
This will produce a 'database' from the table.
Code:Sub MakeData() Dim rngData As Range Dim rngOutput As Range Dim lngRow As Long Dim lngCol As Long Set rngData = Range("B2:J18") Set rngOutput = Range("M1") rngOutput.Resize(1, 3) = Array("Classes", "Employee", "Date") Set rngOutput = rngOutput.Offset(1) For lngRow = 2 To rngData.Rows.Count For lngCol = 2 To rngData.Columns.Count If Len(rngData.Cells(lngRow, lngCol).Value) > 0 Then rngOutput.Offset(0, 0) = rngData.Cells(1, lngCol) ' class rngOutput.Offset(0, 1) = rngData.Cells(lngRow, 1) ' Employee rngOutput.Offset(0, 2) = rngData.Cells(lngRow, lngCol) ' Date Set rngOutput = rngOutput.Offset(1) End If Next Next End Sub
Andy,
You are the man.
This is perfect.
Thanks
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks