+ Reply to Thread
Results 1 to 9 of 9

Remove Forbidden Character

  1. #1
    Registered User
    Join Date
    04-18-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    40

    Remove Forbidden Character

    Hello,

    I'm trying to write a UDF that takes the text in a cell and returns text with a list of forbidden characters removed from it. At the moment I have the following:


    Please Login or Register  to view this content.
    code/

    The problem is that the value in the cell comes out as '#NAME'

    I'd be most grateful for any pointers you may have.

    Thanks,
    twills
    Last edited by twills; 02-04-2010 at 08:19 AM.

  2. #2
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    Re: Remove Forbidden Character

    What is the return type of your function?
    Please Login or Register  to view this content.
    Looking for great solutions but hate waiting?
    Seach this Forum through Google

    www.Google.com
    (e.g. +multiple +IF site:excelforum.com/excel-general/ )

    www.Google.com
    (e.g. +fill +combobox site:excelforum.com/excel-programming/ )

    Ave,
    Ricardo

  3. #3
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Remove Forbidden Character

    Hi, Try changing "Cell as string" to "Txt as string"
    Regards Mick

  4. #4
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    Re: Remove Forbidden Character

    How is this
    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    Re: Remove Forbidden Character

    This would make it a bit more generic
    Please Login or Register  to view this content.
    Call with (like) =SubstituteList("&,/,*,-,|,\,],{,}",C37)

    All should be seperated by comma (,)

  6. #6
    Registered User
    Join Date
    04-18-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    40

    Re: Remove Forbidden Character

    Ricardo and Mike G,

    Many thanks for your suggestions. I incorporate the return type as string as per the suggestions, but still get the #NAME being returned.

    If you have the time, I've attached the worksheet in question and as always would be appreciative of any suggestions.

    Many Thanks,
    Twills
    Attached Files Attached Files

  7. #7
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    Re: Remove Forbidden Character

    Copy the code.

    Delete the module RemoveForbiddenCharacters (save NO)

    Insert new module

    paste the function

    Change (Txt as String) into (Txt as Range)

  8. #8
    Registered User
    Join Date
    04-18-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    40

    Re: Remove Forbidden Character

    Ricardo,

    Many thanks for that - it works perfectly. Incidentally, why does it do this?

    Thanks
    twills

  9. #9
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    Re: Remove Forbidden Character

    Don't know,

    It's hard to tell in someone elses XLS files. therefore I use this method and now it works.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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