+ Reply to Thread
Results 1 to 8 of 8

Userform Textbox Replacing String

  1. #1
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    440

    Userform Textbox Replacing String

    Hi,

    I would like to know how to be able to replace a string after leaving the TextBox?
    Becuz I am working on address and after paste the adress from CanadaPost,
    If the box contain "é", it will be replace by "e". If "Ç" will replace by "C".

    Please help.

  2. #2
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: Userform Textbox Replacing String

    Hi,

    I have attached an example of what I think you're trying to achieve. The address will be entered into cell A1, just for demonstrative purposes. The important piece of code is the following:
    Please Login or Register  to view this content.
    As you can see, I have set up a case for each special character that needs to be replaced. If there are more characters that you need to potentially be replaced, then you could always add another case in before the Case Else statement. You can obtain the necessary character codes from this website (amongst many): http://www.gtwiki.org/mwiki/?title=VB_Chr_Values

    I hope this helps
    Attached Files Attached Files

  3. #3
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: Userform Textbox Replacing String

    Here is an article describing this. While the article describes restricting the textbox to numbers, it is easily adaptable to your requirements.

    Here is an example of restricting to only the alphabet.
    Please Login or Register  to view this content.
    David
    (*) Reputation points appreciated.

  4. #4
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    440

    Re: Userform Textbox Replacing String

    Quote Originally Posted by Tinbendr View Post
    Here is an article describing this. While the article describes restricting the textbox to numbers, it is easily adaptable to your requirements.

    Here is an example of restricting to only the alphabet.
    Please Login or Register  to view this content.
    This only work on keypress. Because the address is copied from Canadapost, so it's a Copy and paste. I have try to use the AfterUpdate, but it doesnt work.

  5. #5
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: Userform Textbox Replacing String

    replace a string after leaving the TextBox?
    Ack! Misread this.

    You could also use Ajryan88's code in the textbox exit event.

  6. #6
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    440

    Re: Userform Textbox Replacing String

    I tried also but it doesnt work:
    Please Login or Register  to view this content.

  7. #7
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: Userform Textbox Replacing String

    How about this then?
    Please Login or Register  to view this content.
    Or maybe this
    Please Login or Register  to view this content.
    Last edited by Tinbendr; 05-28-2014 at 10:08 AM.

  8. #8
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    440

    Re: Userform Textbox Replacing String

    First one work awesome.

+ 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. Replies: 3
    Last Post: 05-07-2012, 09:46 PM
  2. Userform: Convert textbox value from string to type long
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-04-2011, 11:38 AM
  3. Userform Textbox updating a another userform textbox (im stuck!!)
    By wapwap in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-31-2011, 02:56 PM
  4. Userform Button:copy string from one textbox to another
    By wali in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-27-2010, 11:54 AM
  5. Replacing Misspelled sub-string in varying full string
    By freerdj in forum Excel General
    Replies: 15
    Last Post: 08-28-2009, 08:00 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