+ Reply to Thread
Results 1 to 2 of 2

Combining duplicate records into one.

Hybrid View

  1. #1
    Registered User
    Join Date
    07-02-2012
    Location
    london
    MS-Off Ver
    excel 2010
    Posts
    2

    Combining duplicate records into one.

    Hi,

    This is really doing my head in!

    I am trying to find some macro code to enable me to do the below. Any help with this would be greatly appreciated.

    RAW DATA:


    ID MATERIAL1 MATERIAL2 MATERIAL3 MATERIAL4 MATERIAL5
    1 METBB1
    1 METBB1
    1 METBB2
    2 METBB3
    3 METBB1
    3 METBB1

    REQUIRED DATA:

    ID MATERIAL1 MATERIAL2 MATERIAL3 MATERIAL4 MATERIAL5
    1 METBB1 METBB1 METBB2
    2 METBB3
    3 METBB1 METBB1


    Please help??

    David

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Combining duplicate records into one.

    Hi

    Here goes
    Sub aaa()
      For i = 2 To Cells(Rows.Count, 1).End(xlUp).Row
        If Cells(i, 1) <> Cells(i - 1, 1) Then
          outrow = i
        Else
          Cells(outrow, Columns.Count).End(xlToLeft).Offset(0, 1).Value = Cells(i, 2).Value
          Cells(i, 2).ClearContents
        End If
      
      Next i
      
      For i = Cells(Rows.Count, 1).End(xlUp).Row To 2 Step -1
        If Len(Cells(i, 2)) = 0 Then Cells(i, 1).EntireRow.Delete shift:=xlUp
      Next i
    End Sub
    rylo

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1