+ Reply to Thread
Results 1 to 8 of 8

Entering and formatting UK Postcodes into UserForm TextBoxes

  1. #1
    Forum Contributor
    Join Date
    05-08-2009
    Location
    england
    MS-Off Ver
    Excel 2007
    Posts
    223

    Angry Entering and formatting UK Postcodes into UserForm TextBoxes

    Has anyone had any success with trying to validate a UK Postcode into a Userform TextBox entry? I've scoured the internet and am now more confused than before I started...

    As a last resort I was thinking of allowing the entry of a string of letters and numbers, limited to 8 characters (including the space), and inserting the space before the 3rd character from the right once the TextBox is tabbed out of?


    Would that work?


    How would that be coded?


    My head is fried......

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Entering and formatting UK Postcodes into UserForm TextBoxes

    LOL

    It is never that easy

    Format
    A9 9AA
    A99 9AA
    AA9 9AA
    AA99 9AA
    A9A 9AA
    AA9A 9AA
    Last edited by mehmetcik; 08-09-2018 at 03:26 PM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Forum Contributor
    Join Date
    05-08-2009
    Location
    england
    MS-Off Ver
    Excel 2007
    Posts
    223

    Re: Entering and formatting UK Postcodes into UserForm TextBoxes

    Ok,

    Can you please explain how to code the following formula into VBA, assuming it can be done. I've tried copying a recorded Macro but keep getting the "Type Mismatch" error message every which was I play around with it.

    The formula is,

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    05-08-2009
    Location
    england
    MS-Off Ver
    Excel 2007
    Posts
    223

    Re: Entering and formatting UK Postcodes into UserForm TextBoxes

    Well I had a think and a beer and came up with this, seems to work ok,

    Had to put in two textboxes (hidden) to split the postcode up, amended the last three characters to add a space before them and then concatenated them back into the original TextBox.

    Please Login or Register  to view this content.
    I even surprised myself

  5. #5
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Entering and formatting UK Postcodes into UserForm TextBoxes

    How about this ? Without the extra textboxes.
    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: Entering and formatting UK Postcodes into UserForm TextBoxes

    Quote Originally Posted by AndyE View Post
    Ok,

    Can you please explain how to code the following formula into VBA, assuming it can be done. I've tried copying a recorded Macro but keep getting the "Type Mismatch" error message every which was I play around with it.

    The formula is,

    Please Login or Register  to view this content.
    Try
    Please Login or Register  to view this content.

  7. #7
    Forum Expert
    Join Date
    08-02-2013
    Location
    Québec
    MS-Off Ver
    Excel 2003, 2007, 2013
    Posts
    1,412

    Re: Entering and formatting UK Postcodes into UserForm TextBoxes

    Your first question was to validate a UK Postcode into a Userform TextBox entry...
    what about using a Regular expression like this :

    Please Login or Register  to view this content.
    (got the idea here)
    GC Excel

    If this post helps, then click the star icon (*) in the bottom left-hand corner of my post to Add reputation.

  8. #8
    Forum Contributor
    Join Date
    05-08-2009
    Location
    england
    MS-Off Ver
    Excel 2007
    Posts
    223

    Re: Entering and formatting UK Postcodes into UserForm TextBoxes

    Wow! thanks all for the responses.

    Apologies GC, That's brilliant, I did say validate when formatting might have been a better word, only since I wouldn't even know where to being to attempt to try and do that & the code you've supplied.....

+ 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. [SOLVED] Populating userform textboxes basis of results from 2 userform comboboxes
    By rlh in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-11-2017, 10:26 AM
  2. [SOLVED] Dates and formatting TextBoxes in a Userform
    By j_Southern in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-18-2016, 05:34 AM
  3. Formatting UK postcodes
    By Bobjonson in forum Excel General
    Replies: 1
    Last Post: 08-16-2010, 12:38 PM
  4. Entering/Exiting TextBoxes in a Frame
    By magness in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-28-2010, 03:13 PM
  5. Formatting Multiple Userform Textboxes
    By badeye in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-01-2010, 09:14 AM
  6. entering dates into textboxes
    By funkymonkUK in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-06-2005, 05:09 AM
  7. [SOLVED] Default Value formatting... UK Postcodes
    By Scott in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-15-2005, 11:06 AM

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