+ 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
    204

    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
    5,988

    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.
    Please Avoid Joining My List Of Blocked Users by:

    Saying Please and Thank you.

    Making requests not demands.

    Checking back on your post. I will not edit any post after 4 days.

    Marking threads as closed once your issue is resolved. How? The tools at the top

    Any reputation (*) points appreciated. None of us gets paid here.

    If you found someone's input useful, please take a second to click the * at the bottom left to let them know

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

    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
    204

    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
    Excel 2007
    Posts
    4,836

    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
    Posts
    12,937

    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,354

    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 - My blog

    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
    204

    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)

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