PDA

View Full Version : Need to transpose data from rows to columns



Pam in TX
03-23-2015, 01:17 PM
I currently have a file with multiple rows of data per person. Column D has a unique ID # for each person. I need each row of in column H converted to columns beginning in column N creating a new row whenever the ID # changes. The information below are other columns which data remains the same for each ID #.

Column A - Last Name
Column B - First Name
Column C - Grade
Column D - ID
Column E - Home School
Column F - Year
Column G - Math
Column H - Accom Number

Thank you in advance for your assistance.

xld
03-23-2015, 03:12 PM
Public Sub MergeRows()
Dim lastrow As Long
Dim i As Long

Application.ScreenUpdating = False

With ActiveSheet

lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = lastrow To 2 Step -1

If .Cells(i, "D").Value = .Cells(i - 1, "D").Value Then

.Cells(i, "N").Resize(, 100).Copy .Cells(i - 1, "O")
.Cells(i - 1, "N").Value = .Cells(i, "H").Value
.Rows(i).Delete
End If
Next i
End With

Application.ScreenUpdating = True
End Sub