+ Reply to Thread
Results 1 to 5 of 5

Find and return special Chars

Hybrid View

  1. #1
    Registered User
    Join Date
    09-09-2012
    Location
    San Jose, Costa Rica
    MS-Off Ver
    Excel 2007
    Posts
    2

    Find and return special Chars

    Hi,

    I'm looking for a formula that can find and return only the special chars in a string.

    Example:

    String: µGUA BUFFET E LOCA€ċES LTDA
    Return: µ € ċ

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,422

    Re: Find and return special Chars

    In that particular case you could use this:

    =SUBSTITUTE(SUBSTITUTE(A1,"GUA BUFFET E LOCA",""),"ES LTDA","")

    but I suspect you are looking for something more general. You could have a formula with 26 nested SUBSTITUTE functions, each eliminating a single letter, but you could do it more efficiently with a user-defined function (although that would involve a bit of VBA).

    Hope this helps.

    Pete

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Find and return special Chars

    "Special characters" meaning everything except ... what?
    Last edited by shg; 09-10-2012 at 03:31 PM.
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Registered User
    Join Date
    09-09-2012
    Location
    San Jose, Costa Rica
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Find and return special Chars

    Everything except A-Z a-z 0-9 and space

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Find and return special Chars

          -------------A------------- -B- -------C--------
      1   µGUA BUFFET E LOCA€ċES LTDA µ€ċ B1: =Special(A1)
    Function Special(sInp As String) As String
        Static oRE As Object
        
        If oRE Is Nothing Then
            Set oRE = CreateObject("VBScript.RegExp")
            oRE.Global = True
            oRE.IgnoreCase = True
            oRE.Pattern = "[!A-X0-9 ]"
        End If
        Special = oRE.Replace(sInp, "")
    End Function

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1