View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default if cell text repeats, move the adjacent column to the same row

Here is some code to do it

Public Sub ProcessData()
Dim i As Long
Dim LastRow 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

.Cells(i, "B").Resize(, 100).Copy .Cells(i - 1, "C")
.Rows(i).Delete
End If
Next i
End With

End Sub

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"ILoveMyCorgi" wrote in message
...
In the first column I have a student number, the second column the book
title. In the next row the same student number, with a different title,
and
so on until I get to the next student number and a new set of book titles
the
student has checked out. Is there a way using visual basic where the one
unique student number displays with all of the titles for that student in
the
same row?