Compare strings without numbers and characters

probexcel

New Member
Joined
Nov 16, 2022
Messages
14
Office Version
  1. 365
Platform
  1. Windows
I have a column in excel that has some data like that:
  • Alexa 200 Fernandes
  • Alexa 210 Fernandes
  • Alexa 210 Fernandes Melo
  • Google Helpful 235
  • Google Helpful 231
  • Hello World 234 (5x9)
  • Hello World 235 (5x9
What I need to is to check if the text is the same, and if so, to check the highest number. The two first columns are the ones I have in my original Spreadsheet, and the very last one is my desired output. The third one is not really necessary for me, it's only for demonstration purpose. For example:

Original TextNumbersText that needs to be comparedOutput
Alexa 200 Fernandes200Alexa FernandesSell
Alexa 210 Fernandes210Alexa FernandesHold
Alexa 210 Fernandes Melo210Alexa Fernandes Melo
Google Helpful 235235Google HelpfulHold
Google Helpful 231231Google HelpfulSell
Hello World 234 (5x9)234Hello World xSell
Hello World 235 (5x9235Hello World xHold

Basically, what I need in the last column is, IF the extracted letters (no numbers or characters) from row 2 column 1 is equals to the extracted text from any other cell in the column 1, then sell the smaller number in column 2 and hold the higher number in column 2. IF that doesn't happen then just leave it blank.

IF there's 3 different rows that match or more, I only want to sell the smaller number and hold all of the others.

I've spent 2 days trying to figure out a way to do that but still couldn't, so any help and advice would be welcome.
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
How about this using Power Query.

PQ
ABCDEFG
1Original TextNumbersOriginal TextNumbersRNOutput
2Alexa 200 Fernandes200Alexa 200 Fernandes200Alexa FernandesSell
3Alexa 210 Fernandes210Alexa 210 Fernandes210Alexa FernandesHold
4Alexa 210 Fernandes Melo210Alexa 210 Fernandes Melo210Alexa Fernandes Melo
5Google Helpful 235235Google Helpful 235235Google Helpful Hold
6Google Helpful 231231Google Helpful 231231Google Helpful Sell
7Hello World 234 (5x9)234Hello World 234 (5x9)234Hello World xSell
8Hello World 235 (5x9)235Hello World 235 (5x9)235Hello World xHold
Data


Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    RemoveNum = Table.AddColumn(Source, "RN", each Text.Replace(Text.Select([Original Text],{"A".."Z","a".."z"," "}),"  ", " ")),
    Group = Table.Group(RemoveNum, {"RN"}, {{"Data", each _, type table [Original Text=text, Numbers=number, RN=text]}}),
    TC = Table.TransformColumns(Group,{{"Data", (tbl)=> Table.AddColumn(tbl,"Output", each 
        if Table.RowCount(tbl)=1 then null else
        if [Numbers] = List.Min(tbl[Numbers]) then "Sell" else "Hold"
    )}}),
    Expand = Table.ExpandTableColumn(TC, "Data", {"Original Text", "Numbers", "Output"}, {"Original Text", "Numbers", "Output"}),
    Reorder = Table.ReorderColumns(Expand,{"Original Text", "Numbers", "RN", "Output"})
in
    Reorder
 
Upvote 0
Here is another way using excel functions. It uses a defined lambda function 'RemoveCharList', and the formula for that is.
Excel Formula:
=LAMBDA(text,chars,IF(chars="",text,REMOVECHARLIST(SUBSTITUTE(text,LEFT(chars),""),RIGHT(chars,LEN(chars)-1))))

FX
ABCD
14Original TextNumbersNo NumbersOutput
15Alexa 200 Fernandes200Alexa FernandesSell
16Alexa 210 Fernandes210Alexa FernandesHold
17Alexa 210 Fernandes Melo210Alexa Fernandes Melo 
18Google Helpful 235235Google HelpfulHold
19Google Helpful 231231Google HelpfulSell
20Hello World 234 (5x9)234Hello World (x)Sell
21Hello World 235 (5x9)235Hello World (x)Hold
Data
Cell Formulas
RangeFormula
C15:C21C15=TRIM(REMOVECHARLIST(A15,"0123456789"))
D15:D21D15=LET(f,FILTER($B$15:$B$21,$C$15:$C$21=C15),IF(COUNTA(f)=1,"",IF(B15=MIN(f),"Sell","Hold")))
 
Upvote 0
Couldn't get at xl2bb for this. put the formulas down below.

Alexa 200 Fernandes
200​
Alexa FernandesSell
Alexa 210 Fernandes
210​
Alexa FernandesHold
Alexa 210 Fernandes Melo
210​
Alexa Fernandes Melo
Google Helpful 235
235​
Google HelpfulHold
Google Helpful 231
231​
Google HelpfulSell
Hello World 234 (5x9)
234​
Hello World xSell
Hello World 235 (5x9
235​
Hello World xHold
=LET(a," "&A2&" ",b,TEXTSPLIT(a," "),c,SUM(IF(ISNUMBER(VALUE(b)),VALUE(b),"")),c)=LET(a,CODE(MID(A2,SEQUENCE(LEN(A2)),1)),b,FILTER(a,(a>64)*(a<91)+(a>96)*(a<123)+(a=32)),TEXTJOIN("",TRUE,CHAR(b)))=IF(ROWS(FILTER($B$2:$B$8,$C$2:$C$8=C2))>1,IF(MIN(FILTER($B$2:$B$8,$C$2:$C$8=C2))=B2,"Sell","Hold"),"")
 
Upvote 0
Solution

Forum statistics

Threads
1,224,825
Messages
6,181,191
Members
453,021
Latest member
pingpong7117

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