Changing a Excel doc's layout

G

Gregg

I have a program that requires the data in the excel
spreed sheet be laid out in a specif manner but it was
received in another format i.e.

Current layout:

name, id #, job code,job code, job code, hours
sue, 100, 7,8,9, 10,11,12 hours

need it like this:
Name, Id #, Job code, hours
sue, 100,7,10
sue,100,8,11
sue,100,9,12

I have 475 employees in one spreed sheet I need to convert
can someone tell if excel has an easy way or tool that
allows me to reconfigure the layout or will I have to do
it manually, one at a time?
 
J

Jim

u can be helped, lemme knw what exactly the format is n send the attached
file and desired format for fast help!
Jim
 
D

Dave Peterson

Does this mean that your original data has exactly 8 columns (name & id) and 3
columns of Codes followed by 3 columns of hours?

If yes, I'd use a macro that did the work:

Option Explicit
Sub testme()
Dim curWks As Worksheet
Dim newWks As Worksheet
Dim FirstRow As Long
Dim LastRow As Long
Dim iRow As Long
Dim oRow As Long

Set curWks = Worksheets("sheet1")
Set newWks = Worksheets.Add

With curWks
FirstRow = 1
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
oRow = 1
For iRow = FirstRow To LastRow
newWks.Cells(oRow, "A").Resize(3, 1).Value _
= .Cells(iRow, "A").Value
newWks.Cells(oRow, "B").Resize(3, 1).Value _
= .Cells(iRow, "B").Value
newWks.Cells(oRow, "C").Resize(3, 1).Value _
= Application.Transpose(.Cells(iRow, "C").Resize(1, 3).Value)
newWks.Cells(oRow, "d").Resize(3, 1).Value _
= Application.Transpose(.Cells(iRow, "F").Resize(1, 3).Value)
oRow = oRow + 3
Next iRow
End With

End Sub


If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
 

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