Moving multiple rows of data into a single row

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

dmcmo

Thread Starter
Joined
Jan 13, 2011
Messages
2
This has been posted before and I attempted the macro given, but it did not seem to work. It only seemed to copy the data from one sheet to a "new".

Example:
Column A Column B Column C Column D
George 12345 Red Book
George 23456 Blue Television
George 34567 Orange Computer

Need data to appear as follows:
Column A Column B Column C Column D Column E Column F Column G Column H etc
George 12345 Red Book 23456 Blue 34567 Television

In my actual sheet, there 6 columns of data excluding the name (Column A). The rows are multiple.

Can someone possible help?
 
Joined
Sep 4, 2003
Messages
4,912
Please post a sample workbook showing before and after and I'll write the code for you.

Rollin
 

dmcmo

Thread Starter
Joined
Jan 13, 2011
Messages
2
Thank you Rollin! Here is a sample. The 1st row with the name George is how I'd like to see the data. Questions, please let me know! Thank you again!!

Hope I've attached... I'm new at this.
 

Attachments

Joined
Sep 4, 2003
Messages
4,912
Try the code below. It assumes the records have already been sorted by column A.

Code:
Sub MoveRows()

vStart = 2

Do Until Range("A" & vStart).Row = Cells(Rows.Count, "A").End(xlUp).Row + 1

If Range("A" & vStart).Value = Range("A" & vStart + 1).Value Then

Range("B1:G1").Copy Destination:=Cells(1, Cells(vStart, Columns.Count).End(xlToLeft).Column + 1)
Range("B" & vStart + 1 & ":G" & vStart + 1).Copy Destination:=Cells(vStart, Cells(vStart, Columns.Count).End(xlToLeft).Column + 1)
Rows(vStart + 1).Delete

Else

vStart = vStart + 1

End If

Loop

End Sub
Regards,
Rollin
 
Joined
Jan 29, 2011
Messages
1
After tweaking the code a bit (I needed one more column included) this appears to have worked. You have saved me countless man hours on my dissertation. Thank you!
 
Joined
Sep 4, 2003
Messages
4,912
Glad you got this one sorted. Please mark the thread as solved when you get a chance.

Rollin
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top