1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Moving multiple rows of data into a single row

Discussion in 'Business Applications' started by dmcmo, Jan 13, 2011.

Thread Status:
Not open for further replies.
Advertisement
  1. dmcmo

    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?
     
  2. Rollin_Again

    Rollin_Again

    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
     
  3. dmcmo

    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.
     

    Attached Files:

  4. Rollin_Again

    Rollin_Again

    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
     
  5. Kiltmann

    Kiltmann

    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!
     
  6. Rollin_Again

    Rollin_Again

    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
     
  7. Sponsor

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 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/974556

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice