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: 17
Last edited by a moderator:

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
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,215,747
Messages
6,126,652
Members
449,326
Latest member
asp123

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