• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to remove special characters and words from a cell value.

Fred Wayne

Member
I need to remove the "*", the second word(Name), and the comma from a cell value. For example in cell B1 says *Chen,Hao,Mr.
I need that in cell C1, the asterisk, the 2 commas, and the name "Hao" to not be taken into account. So what I want is that in cell C1 to appear like this:
"Chen Mr.", the same thing will be for the rest of the names.

Is there a formula to get this done?

I am attaching an image of what I need and the original file.
 

Attachments

  • remove.PNG
    remove.PNG
    25.9 KB · Views: 12
  • Remove.xlsm
    Remove.xlsm
    10.7 KB · Views: 8
Power Query Solution

Code:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Split Column by Delimiter" = Table.SplitColumn(Source, "Column1", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Column1.1", "Column1.2", "Column1.3"}),
    #"Replaced Value" = Table.ReplaceValue(#"Split Column by Delimiter","*","",Replacer.ReplaceText,{"Column1.1"}),
    #"Merged Columns" = Table.CombineColumns(#"Replaced Value",{"Column1.1", "Column1.3"},Combiner.CombineTextByDelimiter(" ", QuoteStyle.None),"Merged"),
    #"Removed Columns" = Table.RemoveColumns(#"Merged Columns",{"Column1.2"})
in
    #"Removed Columns"
 
Hi to all!

One option could be:
[C1] : =TRIM(CONCAT(MID(SUBSTITUTE(SUBSTITUTE(B1,"*",""),",",REPT(" ",99)),1+99*{0;2},99)))
And drag it down. Blessings!
 
I just moved some cells down but just changed B1 for B2, but didn`t work.
=TRIM(CONCAT(MID(SUBSTITUTE(SUBSTITUTE(B2,"*",""),",",REPT(" ",99)),1+99*{0;2},99)))
 
I have tried but it gives me an error
I think you don't have CONCAT function, of which only available in Excel 2019 or Office 365

Or,

you could try this formula instead, in C1 formula copied down :

=SUBSTITUTE(LEFT(B1,FIND(",",B1)-1),"*","")&" "&MID(B1,1-LOOKUP(,-FIND(",",B1,ROW(A:A))),9)

Regards
 
Power Query is a free AddIn for Excel 2010 and 2013, and is built-in functionality from Excel 2016 onwards (where it is referred to as "Get & Transform Data").

It is a powerful yet simple way of getting, changing and using data from a broad variety of sources, creating steps which may be easily repeated and refreshed. I strongly recommend learning how to use Power Query - it's among the most powerful functionalities of Excel.

- Follow this link to learn how to install Power Query in Excel 2010 / 2013.

- Follow this link for an introduction to Power Query functionality.

- Follow this link for a video which demonstrates how to use Power Query code provided.
 
Back
Top