+ Reply to Thread
Results 1 to 5 of 5

Create UDF that remove specific characters

Hybrid View

YasserKhalil Create UDF that remove... 04-24-2017, 09:18 PM
MrShorty Re: Create UDF that remove... 04-25-2017, 12:00 AM
YasserKhalil Re: Create UDF that remove... 04-25-2017, 04:08 AM
MrShorty Re: Create UDF that remove... 04-25-2017, 09:01 AM
YasserKhalil Re: Create UDF that remove... 04-26-2017, 05:40 AM
  1. #1
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Create UDF that remove specific characters

    Hello everyone
    In Arabic the letters system is different from English. The letters may be sometimes have addition of special characters (separated from the original letter)
    I need a UDF that removes those characters
    Example: the word "أَظْهَرَ" is the word with those special characters ... I need to return the same word without those special characters .. in that way "أظهر"

    Please help me in this topic. I think it may be solved using Ascii excluding the undesired characters
    Thanks advanced for help

    The issue posted at this link first
    http://www.eileenslounge.com/viewtop...206194#p206194
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,385

    Re: Create UDF that remove specific characters

    What part of putting this UDF together would you need help with? The hardest part, IMO, is looking up the UNICODE character numbers for the "letter + special" and the "letter alone" characters. Once you have those values, then it should be a simple Replace() function in VBA or a SUBSTITUTE() function if you want to use native Excel functions.
    Replace function help file: https://msdn.microsoft.com/en-us/lib.../gg264409.aspx

    If it helps get you started, I used the AscW() function in VBA to find that the 2nd character in your first string is unicode #1614 decimal/64E hexadecimal. The 2nd character in the replaced string is unicode # 1592 decimal/638 hexadecimal. So a statement like newstring=replace(inputstring,chrw(1614),chrw(1592)) would make this replacement. I would expect the UDF to look something like
    function replacechar(instring as string) as string
    'code to build array of characters to search for
    'code to build array of characters to replace
    for each character in search/replace arrays
    newstring=replace(instring,search character,replace character)
    next character
    replacechar=newstring
    error checking as needed
    end function
    The hardest (because it is tedious) is searching through the Unicode character lists to get the character codes and putting those characters into arrays. Wikipedia has this list: https://en.wikipedia.org/wiki/Arabic_script_in_Unicode I'm sure there are others.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Create UDF that remove specific characters

    Thanks a lot MrShorty for reply
    I tried that function and it worked for the example provided
    Function FnReplace(S As Range) As String
        Dim O, R, N As Long, T As String
        T = S.Value
    
        O = Array("َ", "ْ", "ً")
        
        R = Array("", "", "")
    
        For N = LBound(O) To UBound(O)
            FnReplace = Replace(T, O(N), R(N)): T = FnReplace
        Next N
    
        FnReplace = T
    End Function
    And it worked well .. but in fact I can't store those special characters in an array as those special characters are much
    Can you have a look at the Unicode table to do that if possible?

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,385

    Re: Create UDF that remove specific characters

    but in fact I can't store those special characters in an array as those special characters are much
    I'm not understanding what difficulty you are having. Looking at the eileen's lounge thread, it appears that you are having difficulty with the tedious part of reading and typing in the characters and codes. I cannot tell if it is simply "it is too long and tedious and I get bored doing it" or if there is some other difficulty in reading the UNICODE tables at wikipedia. If you are having trouble reading wikipedia's unicode tables, there are others out there.

    Your sample list in the other forum did not include any of the Arabic characters, but did include the Latin characters. Is the problem larger than originally indicated, in that you don't want to limit this to just the Arabic characters, but the entire Unicode list where accent and other special marks are part of the character? Other than being longer and more tedious, I don't know that this problem is more difficult.

    One thing I noticed in the spreadsheet on the other forum is that you used the CHAR() function -- which is limited to Ascii character codes. In 2013, you have access to the built in UNICHAR() (and UNICODE()) functions. https://support.office.com/en-us/art...90033e188#bm21 Paste your code list into Excel like you started, then use the UNICODE() function instead of the CODE() function to get the list of decimal Unicode() numbers for each character. That will even give you the beginnings of a lookup table that you might be able to use.

    Does any of that help? What are you stuck on?

  5. #5
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Create UDF that remove specific characters

    I am sorry MrShorty for being late in reply. Thanks a lot for your guidance
    The problem is solved efficiently by Mr. Hans using ASCW method

    Thank you very much for helping me

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Remove Text characters, leaving numerical characters
    By aschwalge in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 02-01-2016, 06:42 PM
  2. [SOLVED] VBA, remove all characters within a string, except numerical characters and full stops
    By rain4u in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-25-2015, 09:24 PM
  3. Remove Specific Characters From Text Cell
    By chasfh in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-18-2014, 10:38 AM
  4. How to keep hyphen in a string and remove all specific characters
    By SunOffice in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-27-2013, 12:32 AM
  5. [SOLVED] VBA Remove Specific No.of Characters
    By hobbiton73 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-22-2013, 05:39 AM
  6. Want to Remove A Non-Specific Text Strand Between Two Specific Characters
    By predictablepanda in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-04-2013, 12:33 AM
  7. Formatting to remove specific characters
    By tisentes13 in forum Excel General
    Replies: 4
    Last Post: 10-13-2009, 04:34 PM

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