Extract every words, after certain character, in any position within a cell. Then split

superjoejoe

New Member
Joined
Jul 2, 2020
Messages
4
Office Version
  1. 2019
Platform
  1. Windows

Attachments

  • tanya.png
    tanya.png
    30.7 KB · Views: 21
Last edited by a moderator:

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Assuming your data as follows.
varios 06jul2020.xlsm
ABCDE
1List
2Chrismas, Festive, OuterwearOuterwearChrismas, FestiveTop
3Chinese New Year, SetsSetsChinese New YearOuterwear
4ShoesShoesSets
5Shoes
6and so on
7
8
9
Hoja4

Try this:

VBA Code:
Sub test()
  Dim c As Range, rList As Range, f As Range
  Dim sWord As Variant, cad1 As String, cad2 As String
  
  Set rList = Range("E2", Range("E" & Rows.Count).End(3))
  For Each c In Range("A2", Range("A" & Rows.Count).End(3))
    cad1 = ""
    cad2 = ""
    For Each sWord In Split(c, ",")
      Set f = rList.Find(Trim(sWord), , xlValues, xlWhole)
      If Not f Is Nothing Then
        cad1 = cad1 & Trim(sWord) & ", "
      Else
        cad2 = cad2 & Trim(sWord) & ", "
      End If
    Next sWord
    If cad1 <> "" Then c.Offset(, 1).Value = Left(cad1, Len(cad1) - 2)
    If cad2 <> "" Then c.Offset(, 2).Value = Left(cad2, Len(cad2) - 2)
  Next c
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,747
Messages
6,180,714
Members
452,995
Latest member
isldboy

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