+ Reply to Thread
Results 1 to 5 of 5

Lock character during entry in UserForm textbox

  1. #1
    Forum Contributor
    Join Date
    04-03-2012
    Location
    Washington State
    MS-Off Ver
    Excel 365
    Posts
    340

    Lock character during entry in UserForm textbox

    Hi,

    I am using a textbox in a userform to enter time and I want to reduce errors and reduce time to make entries and I was wondering if there is a way to lock the colon between numbers.

    The user will be entering 2 digits for minutes and 2 digits for seconds. What I would like to do is automate the entry a little bit and have the colon placed in the textbox for them after the first one or two digits. How can this be done?

    I have tried:

    Please Login or Register  to view this content.
    But this just fills the textbox up with a bunch of colons.... "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::"
    Thanks for any help!

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Lock character during entry in UserForm textbox

    You need add the colon after the first 2 characters, so check for when 2 characters have been entered.
    Please Login or Register  to view this content.

  3. #3
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Lock character during entry in UserForm textbox

    Hello Nu2Java,

    Try it like this with the AfterUpdate Event.

    Please Login or Register  to view this content.
    Assuming you are using military time, that would handle a situation where a user enters 730, instead of 0730.

    Also see the "Please consider" note at the bottom of this post.
    Last edited by Winon; 11-04-2012 at 05:01 AM.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  4. #4
    Forum Contributor
    Join Date
    04-03-2012
    Location
    Washington State
    MS-Off Ver
    Excel 365
    Posts
    340

    Re: Lock character during entry in UserForm textbox

    Thanks Norie & Winon

    Norie, thanks for the code. I realized the mistake I made with ">= 1" .... DOH! I went with Winon's code so I can have the user enter 1 or 2 digits for the minutes and it will enter 0 if not a 2 digit number which works great. I want to thank both of you for your time and help, it is very much appreciated.

  5. #5
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Lock character during entry in UserForm textbox

    Hello Nu2Java,

    You are welcome.

    Thank you for the feedback.

    Glad we could help.

    Thank you for the Rep.

+ 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