combine two columns if same value

i DOCID  in column A

1111111111
44444
44444
8888888


in column AO
experience.organization.name - Behavioral
experience.organization.name - psych
experience.organization.name - Behavioral
experience.organization.name - Behavioral
 


I want to combine the values in AO where the values are the same in column A

so values would become this (only need to do it for the first one)

experience.organization.name - Behavioral
experience.organization.name - psych, experience.organization.name - Behavioral
experience.organization.name - Behavioral,
experience.organization.name - Behavioral


NOTE, it is sorted on column A , and the tricky part is some have 3 matches, other have 4, 5 , 6 etc

I WOULD ALSO need a value put in column AP so i know which rows got appended more data
finnstoneAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Neil FlemingConsultant and developerCommented:
Can you post your workbook? Code to do this will be relatively simple.
0
finnstoneAuthor Commented:
here is some of it, 100 rows
Book1.xlsx
0
finnstoneAuthor Commented:
any ideas?
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Neil FlemingConsultant and developerCommented:
try this:

Click button to routine below:
Sub Combine()
Dim rSource As Range, rComp As Range, rTarget As Range

'set source for id
Set rSource = ActiveSheet.Range("a2")


'set target cell
'Set rTarget = ActiveSheet.Range("ao2")
Set rTarget = ActiveSheet.Range("ao2")

Do
'set cell to compare
Set rComp = rSource
    Do
    'move comparison cell down one row
    Set rComp = rComp.Offset(1, 0)
        If rComp = rSource Then
        'add to target cell
        rTarget = rTarget & ", " & rTarget.Offset(rComp.Row - rSource.Row, 0)
        Set rComp = rComp.Offset(-1, 0)
        'delete row where DOCID is identical
        rComp.Offset(1, 0).EntireRow.Delete
        
        End If
    'loop until blank cell
    Loop Until rComp = ""
'next source row
Set rSource = rSource.Offset(1, 0)
'loop till blank
Loop Until rSource = ""

End Sub

Open in new window

combine-columns.xlsm
0
finnstoneAuthor Commented:
can this be run on 20k rows? its been working for 5 minutes
0
finnstoneAuthor Commented:
this doesnt work!
0
finnstoneAuthor Commented:
doesnt even work for the sample you provided.
0
Neil FlemingConsultant and developerCommented:
Strange. I just re-downloaded, and ran it. Can you explain what it is it that is not working? (It was your sample, btw.)

I get the attached result after running the code. The result has no identical keys in column A, and all the results collated in column AO as requested.
combine-columns2.xlsm
0
finnstoneAuthor Commented:
thx.

USbc4852fa730f2e61


this should be

industry - Hospital Health Care; experience.organization.name - Psychiatric, industry - Hospital Health Care, headline - Behavioral, industry - Hospital Health Care; experience.organization.name - Psychiatric
0
Neil FlemingConsultant and developerCommented:
Ah. There was a missing line of code that was not keeping the "target" in synch with the "source". Apologies.

Also it wasn't handling blank entries properly.

Try the revised attached.

And yes, it will run on 20,000 lines, but probably quite slowly. It would be much faster if we could sort the rows by ID first, but not sure if you want to do that.

I've set it to scroll to and select the row it is currently working on so you can see progress.
combine-columns3.xlsm
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
finnstoneAuthor Commented:
EXCELLENT

Thanks
0
finnstoneAuthor Commented:
amazing code
1
Neil FlemingConsultant and developerCommented:
thank you. Sorry it didn't work properly first time around.. :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VBA

From novice to tech pro — start learning today.