String Manipulation - Delete Data occuring multiple times in a cell

Blessy Clara

Board Regular
Joined
Mar 28, 2010
Messages
204
Office Version
  1. 365
Platform
  1. Windows
[TABLE="width: 500"]
<tbody>[TR]
[TD][TABLE="width: 374"]
<tbody>[TR]
[TD="class: xl63, width: 374"]Youth Service - NEET / Youth Payment, Support and Training for Service Providers - Education, Programmes for Young People, Elder abuse,Local Community, Elder abuse[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD][TABLE="width: 374"]
<tbody>[TR]
[TD="class: xl65, width: 374"]Intellectual Disabilities, Finding work, Community Courses, Work[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD][TABLE="width: 374"]
<tbody>[TR]
[TD="class: xl65, width: 374"]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[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD][TABLE="width: 374"]
<tbody>[TR]
[TD="class: xl65, width: 374"]Other budgeting services, Local Community, Holiday / Before / After School Programmes,Parenting - Skills and Support, Holiday / Before / After School Programmes, Community Courses[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]Required
[TABLE="width: 500"]
<tbody>[TR]
[TD]Other budgeting services, Local Community, Holiday / Before / After School Programmes,Parenting - Skills and Support, Community Courses[/TD]
[/TR]
[TR]
[/TR]
</tbody>[/TABLE]

[/TD]
[/TR]
</tbody>[/TABLE]

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

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
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,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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