View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bob Phillips[_3_] Bob Phillips[_3_] is offline
external usenet poster
 
Posts: 2,420
Default Advice/best practice needed maybe some complex VB aswell

Public Sub ProcessData()
Dim i As Long
Dim LastRow As Long
Dim LastCol As Long

With ActiveSheet

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

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

LastCol = .Cells(i, .Columns.Count).End(xlToLeft).Column
.Cells(i, "B").Resize(, LastCol - 1).Copy .Cells(i - 1, "D")
.Rows(i).Delete
End If
Next i
End With

End Sub


--
__________________________________
HTH

Bob

"ArcticWolf" wrote in message
...
Hi,

I have a table which lists employee name, their exam name and grade (table
1).

Table 1
Row 1 Holmer Simpson,Exam 1,Pass
Row 2 Holmer Simpson,Exam 2,Pass
Row 3 Holmer Simpson,Exam 3,Fail
Row 4 Holmer Simpson,Exam 4,Distinction
Row 5 Marge Simpson,Exam1,Pass
Row 6 Marge Simpson,Exam 2,Pass
Row 7 Bart Simpson,Exam 1,Distinction
Row 8 Bart Simpson,Exam 2,Pass
Row 9 Bart Simpson,Exam 3,Pass

I need to get all the data for each person onto one row (table 2).

Table 2
Row 1 Holmer Simpson,Exam 1,Pass,Exam 2,Pass,Exam 3,Fail,Exam
4,Distinction
Row 2 Marge Simpson,Exam1,Pass,Exam 2,Pass,,,,
Row 3 Bart Simpson,Exam 1,Distinction,Exam 2,Pass,Exam 3,Pass,,

I started copying and pasting the 2nd, 3rd & 4th exam etc into the 1st row
of each employee (using the next empty column within the row) and I then
deleted the empty rows. My original table contains over 5000 rows so it's
going to take an age plus any human errors in the copy paste.

Is there a way in which I can get to table 2 maybe with some wizzy VB
please, or maybe there is another solution? I tried putting it into a
pivot
table but I can't get exam names to list properly.

Any advice would be appreciated.

TIA,

AW