I have supplier name together with product name in one cell as a string.
Each cell has a word that's all uppercase (sometimes with a digit or a number).
Data | I need to extract |
---|---|
3LAB Anti - Aging Oil 30ml | 3LAB |
3LAB Aqua BB SPF40 #1 14g | 3LAB |
3LAB SAMPLE Perfect Neck Cream 6ml | 3LAB |
3LAB SAMPLE Super h" Serum Super Age-Defying Serum 3ml" | 3LAB |
3LAB TTTTT Perfect Mask Lifting Firming Brightening 28ml | 3LAB |
3LAB The Cream 50ml | 3LAB |
3LAB The Serum 40ml | 3LAB |
4711 Acqua Colonia Intense Floral Fields Of Ireland EDC spray 170ml | EDC |
4711 Acqua Colonia Intense Pure Brezze Of Himalaya EDC spray 50m" | EDC |
I need to extract only that UPPERCASE supplier name to a new cell.
I've tried to create User Defined Function like this one, but it's not working.
It's returning #NAME?
error.
Public Function UpperCaseWords(S As String) As String
Dim X As Long
Dim TempText As String
TempText = " " & S & " "
For X = 2 To Len(TempText) - 1
If Mid(TempText, X, 1) Like "[!A-Z ]" Or Mid(TempText, X - 1, 3) Like "[!A-Z][A-Z][!A-Z]" Then
Mid(TempText, X) = " "
End If
Next
UpperCaseWords = Application.Trim(TempText)
End Function
Any idea how to correct it and make it work?
I've found it here: https://www.mrexcel.com/board/threads/formula-to-extract-upper-case-words-in-a-text-string.684934/page-2#posts
And why in this macro, in line For X = 2 To Len(TempText) - 1
the X
is set to 2?
"``` in the formula, because I don't understand these XML marks. Is this a fast formula? Because I have over 250 000 rows I need to run it against. And also can you explain how you've created this ```"//s[.*0!=0][translate(.,'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789','')='']"``` ??