if cell text repeats, move the adjacent column to the same row
THANK YOU!!! You just made my life a little easier... Now I can incorporate
the output with another list for a longer row of data I plan to use later.
Thanks a million! susan
"Gary''s Student" wrote:
This example assumes that the original data is on Sheet1 and the revised
format will be entered in Sheet2:
Sub newlist()
Set w1 = Sheets("Sheet1")
Set w2 = Sheets("Sheet2")
w2.Cells(1, 1).Value = w1.Cells(1, 1).Value
w2.Cells(1, 2).Value = w1.Cells(1, 2).Value
Ide = Cells(1, 1).Value
w1.Activate
n = Cells(Rows.Count, 1).End(xlUp).Row
k = 3
kk = 1
For i = 2 To n
If w1.Cells(i, 1).Value = Ide Then
w2.Cells(kk, k).Value = w1.Cells(i, 2).Value
k = k + 1
Else
kk = kk + 1
k = 3
Ide = w1.Cells(i, 1).Value
w2.Cells(kk, 1).Value = Ide
w2.Cells(kk, 2).Value = w1.Cells(i, 2).Value
End If
Next
End Sub
--
Gary''s Student - gsnu200772
"ILoveMyCorgi" wrote:
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?
|