+ Reply to Thread
Results 1 to 6 of 6

duplication with lastName split and a twist :)

  1. #1
    Registered User
    Join Date
    02-21-2007
    Posts
    8

    Question duplication with lastName split and a twist :)

    hi all,
    Have joined data together so that where column A to B had same data but C had different data we joined C (with an "&" between each value) and deleted the A and B duplicate rows
    I now need to do the opposite with a twist
    I now need to split it up again but also need to split the name field up further so that last name is separate to other names.

    An example of the data in its current form is below
    Cell A1= 5
    Cell B1= Bellrose Plaza Someplace 4444
    Cell C1= Bob Marley & John Lennon
    Cell A2= 6
    Cell B2= Bellrose Plaza Someplace 4444
    Cell C2 = Jack Johnson & Pete Murray

    As you can see check for duplication was based on Row A and B

    How I need it is:
    Cell A1= 5
    Cell B1= Bellrose Plaza Someplace 4444
    Cell C1= Bob
    Cell D1= Marley
    Cell A2= 5
    Cell B2= Bellrose Plaza Someplace 4444
    Cell C2= John
    Cell D2= Lennon
    Cell A3= 6
    Cell B3= Bellrose Plaza Someplace 4444
    Cell C3= Jack
    Cell D3= Johnson
    Cell A3= 6
    Cell B3= Bellrose Plaza Someplace 4444
    Cell C3= Pete
    Cell D3= Murray


    Below is the Macro that i used to delete and merge them in the first place
    (I added another row into the match also that are not important in the reversal)

    Sub DeleteAndMerge()

    Dim i As Long
    Dim dCol As Long
    Dim lrow As Long

    'Column to check first (A)
    dCol = 1

    'Get last row of data, Col A
    lrow = Cells(65536, dCol).End(xlUp).Row

    'Check each row: lastrow to row 2
    For i = lrow To 2 Step -1

    'If Col A AND Col B are match
    If Cells(i, 1) = Cells(i - 1, 1) And Cells(i, 2) = Cells(i - 1, 2) And Cells(i, 4) = Cells(i - 1, 4) Then

    'Col C = Concatentate Col C names
    Cells(i - 1, 3) = Cells(i - 1, 3) & " & " & Cells(i, 3)

    'Delete dupe row
    Cells(i, 1).EntireRow.Delete
    End If
    Next i
    End Sub

    My guess would be to count "&" in row C and then insert number of rows accordingly, then duplicate A and B down.
    then split C down into seporate rows according to when it finds "&"
    then seporate last term from each of those columns into a new column
    I know what needs to be done, just need some help to write it
    Any help would be greatly appriciated
    Appologies for the long description

  2. #2
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628
    See the attached file... I added a macro that may be what you need.

    Regards,
    Antonio
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    02-21-2007
    Posts
    8

    Smile Perfect.. except for one little thing

    That is awesome.
    Thankyou soo much for that.. you have saved me hours of work
    How could i change it though to only split the last word of the "name" (C) cell
    eg: Bob Francis Marley in one cell to start with and then "Bob Francis" in one and "Marley" in another (at the moment it splits into a new cell whenever it finds a space

  4. #4
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628
    See the attached file.

    For each name I take the last blank to divide string in two strings to put in column C and D

    I hope it's what you need.

    Regards,
    Antonio
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    02-21-2007
    Posts
    8

    Spot on :)

    Hey,
    that one did the trick
    I just added in to include the duplication for some other columns and it worked a treat.
    Thanks Again

  6. #6
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628
    I'm pleased to know it can help you.

    Have a nice time,
    Antonio

+ 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