+ Reply to Thread
Results 1 to 11 of 11

Separate two year values in a textbox with a slash - vba

  1. #1
    Registered User
    Join Date
    09-23-2019
    Location
    Ghana
    MS-Off Ver
    2016 32 bit and 64 bit
    Posts
    92

    Separate two year values in a textbox with a slash - vba

    I want to enter into a textbox

    2019/2020

    So what I want to do is to make sure that only numbers and the forward slash is allowed. No spaces accepted.

    So when I enter 2019 then the slash comes automatically. Then I add the other year.

    My knowledge is limited on that trick and I need Tech support.

    Thanks

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Separate two year values in a textbox with a slash - vba

    Hello Kelly,

    Where is the TextBox: Worksheet or UserForm?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    09-23-2019
    Location
    Ghana
    MS-Off Ver
    2016 32 bit and 64 bit
    Posts
    92

    Re: Separate two year values in a textbox with a slash - vba

    Quote Originally Posted by Leith Ross View Post
    Hello Kelly,

    Where is the TextBox: Worksheet or UserForm?
    On a userform

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Separate two year values in a textbox with a slash - vba

    Hello Kelly,

    Thanks for letting me know. I will write the code and post it.

  5. #5
    Registered User
    Join Date
    09-23-2019
    Location
    Ghana
    MS-Off Ver
    2016 32 bit and 64 bit
    Posts
    92

    Re: Separate two year values in a textbox with a slash - vba

    Quote Originally Posted by Leith Ross View Post
    Hello Kelly,

    Thanks for letting me know. I will write the code and post it.
    Okay. Sure. I am waiting

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Separate two year values in a textbox with a slash - vba

    Hello Kelly,

    Sorry, I got slammed with phone calls. Here is the code. I used TextBox1. If your TextBox name is different then change it in the macro.

    Set your TextBox property MaxLength to 9. This will limit the input to only 9 characters and no more.

    Please Login or Register  to view this content.

  7. #7
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Separate two year values in a textbox with a slash - vba

    I think reset the slash would be
    Please Login or Register  to view this content.
    As when using backspace after the slash is inserted, the code doesn't insert it again
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  8. #8
    Registered User
    Join Date
    09-23-2019
    Location
    Ghana
    MS-Off Ver
    2016 32 bit and 64 bit
    Posts
    92

    Re: Separate two year values in a textbox with a slash - vba

    Cool. One thing I observed is that after I use the delete keys, the validation does no longer work.

    I don't know if you can also duplicate this issue at your end.

  9. #9
    Registered User
    Join Date
    09-23-2019
    Location
    Ghana
    MS-Off Ver
    2016 32 bit and 64 bit
    Posts
    92

    Re: Separate two year values in a textbox with a slash - vba

    Quote Originally Posted by YasserKhalil View Post
    I think reset the slash would be
    Please Login or Register  to view this content.
    As when using backspace after the slash is inserted, the code doesn't insert it again
    I think your line resolved the previous concern I raised.

  10. #10
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Separate two year values in a textbox with a slash - vba

    Interesting. I tested the code and had no problems.

  11. #11
    Registered User
    Join Date
    09-23-2019
    Location
    Ghana
    MS-Off Ver
    2016 32 bit and 64 bit
    Posts
    92

    Re: Separate two year values in a textbox with a slash - vba

    Quote Originally Posted by Leith Ross View Post
    Interesting. I tested the code and had no problems.

    I appreciate your help. Now this thread can be marked as "solved". Thanks

+ 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. How to Parse Street, City, State, and Zip Code into Separate Values. In Textbox
    By jarekmos in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-27-2017, 05:30 PM
  2. [SOLVED] sumproduct to count year values in range based on another cell year value
    By mr_mango81 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 05-04-2017, 12:46 AM
  3. [SOLVED] Separate two dates with a slash
    By enhydra in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-23-2017, 12:57 PM
  4. Replies: 2
    Last Post: 08-21-2014, 01:27 PM
  5. fill dot or slash automatically to date in Textbox
    By elevisse in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-09-2012, 07:15 AM
  6. Userform to search textbox value to place other textbox values in worksheet
    By mattyh555 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-19-2012, 11:38 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