arranging data - Pivot Table?

S

Susie

I have been given a file with data laid out in the
following format.

Name Type Beg Add W/D End Type Beg Add W/D End

A 1 0 2 0 2 2 1 4 0 5
B 1 2 1 1 2 3 1 0 1 0


I need the data in the following format.

Name Type Beg Add W/D End
A 1 0 2 0 2
A 2 1 4 0 5
B 1 2 1 1 2
B 3 1 0 1 0

Each type actually has 10 columns of data and some files
have up to 8 types and hundreds of names.

I tried using a pivot table but have not had any success.

Thanks for your help.
 
E

Earl Kiosterud

Susie,

A Pivot Table won't do what you want. It summarizes. You need a layout
change, and probably only a macro will do it. We can write you one, if
you're interested. I'm not sure we have enough info about your table yet.

You're on the right track to making your table a more usable database table.
 
D

Dave Peterson

Does that mean that you have 101 columns per row?

if yes, then how about:

Option Explicit
Sub testme01()

Dim curWks As Worksheet
Dim newWks As Worksheet
Dim iRow As Long
Dim iCol As Long
Dim FirstRow As Long
Dim LastRow As Long
Dim iStep As Long
Dim oRow As Long

Set curWks = ActiveSheet
Set newWks = Worksheets.Add

iStep = 10 'groups of 10
newWks.Range("a1").Resize(1, iStep + 1).Value _
= curWks.Range("a1").Resize(1, iStep + 1).Value

iStep = 10 'groups of 10
oRow = 2
With curWks
FirstRow = 2
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

For iRow = FirstRow To LastRow
For iCol = 2 To .Cells(iRow, _
.Columns.Count).End(xlToLeft).Column Step iStep
newWks.Cells(oRow, "A").Value = .Cells(iRow, "A").Value
newWks.Cells(oRow, "B").Resize(1, iStep).Value _
= .Cells(iRow, iCol).Resize(1, iStep).Value
oRow = oRow + 1
Next iCol
Next iRow
End With

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top