String Manipulation - Delete Data occuring multiple times in a cell

Blessy Clara

Board Regular
Joined
Mar 28, 2010
Messages
201
Youth Service - NEET / Youth Payment, Support and Training for Service Providers - Education, Programmes for Young People, Elder abuse,Local Community, Elder abuse

<tbody>
</tbody>
Intellectual Disabilities, Finding work, Community Courses, Work

<tbody>
</tbody>
Sexual harm / sexual violence,Victim / survivor of family violence,Violent person, Sexual harm / sexual violence, Crime and Its Effects,Sexual harm / sexual violence, Counselling,Crime and Its Effects,Sexual harm / sexual violence,Women, Counselling - Youth,Helplines and Information Services - Youth, Counselling

<tbody>
</tbody>
Other budgeting services, Local Community, Holiday / Before / After School Programmes,Parenting - Skills and Support, Holiday / Before / After School Programmes, Community Courses

<tbody>
</tbody>
Required
Other budgeting services, Local Community, Holiday / Before / After School Programmes,Parenting - Skills and Support, Community Courses

<tbody>
</tbody>


<tbody>
</tbody>

I would like to remove a term occurring multiple times within the cell
Sometimes the word may occur as Health, Health - Mental, Health - Gynec, Health
Do not remove Health occurring as Health - Mental, Health Gyenec - Delete only Health

Clue - the words are separated by Comma
Thank you in advance
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Hi, here is a UDF that you can try.

To use:
1. With your spreadsheet open, press ALT+F11 to open the VBE.
2. Click "Insert" > "Module" on the menu bar.
3. Copy and paste the code below into the blank window on the top right hand side.
4. Press ALT+Q to close the VBE
5. Save your workbook as a macro enabled workbook (xlsm)
6. Use just like any another worksheet function as demonstrated below.

Code:
Function RemoveDupText(s As String)
Dim v
For Each v In Split(s, ",")
  If InStr(1, ", " & RemoveDupText & ", ", ", " & Trim(v) & ", ", vbTextCompare) = 0 Then
    RemoveDupText = RemoveDupText & ", " & Trim(v)
  End If
Next v
RemoveDupText = Mid(RemoveDupText, 3)
End Function


Excel 2013/2016
AB
1Youth Service - NEET / Youth Payment, Support and Training for Service Providers - Education, Programmes for Young People,Elder abuse,Local Community,Elder abuseYouth Service - NEET / Youth Payment, Support and Training for Service Providers - Education, Programmes for Young People, Elder abuse, Local Community
2Intellectual Disabilities, Finding work, Community Courses, WorkIntellectual Disabilities, Finding work, Community Courses, Work
3Sexual harm / sexual violence,Victim / survivor of family violence,Violent person,Sexual harm / sexual violence, Crime and Its Effects,Sexual harm / sexual violence, Counselling,Crime and Its Effects,Sexual harm / sexual violence,Women, Counselling - Youth,Helplines and Information Services - Youth, CounsellingSexual harm / sexual violence, Victim / survivor of family violence, Violent person, Sexual harm / sexual violence, Crime and Its Effects, Counselling, Women, Counselling - Youth, Helplines and Information Services - Youth
4Other budgeting services, Local Community, Holiday / Before / After School Programmes,Parenting - Skills and Support,Holiday / Before / After School Programmes, Community CoursesOther budgeting services, Local Community, Holiday / Before / After School Programmes, Parenting - Skills and Support, Holiday / Before / After School Programmes, Community Courses
Sheet1
Cell Formulas
RangeFormula
B1=RemoveDupText(A1)
 
Upvote 0

Forum statistics

Threads
1,213,534
Messages
6,114,186
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top