+ Reply to Thread
Results 1 to 10 of 10

Numeric code in textbox

  1. #1
    Registered User
    Join Date
    05-06-2012
    Location
    Lisbon,Portugal
    MS-Off Ver
    Excel 2010
    Posts
    79

    Numeric code in textbox

    Please Login or Register  to view this content.

  2. #2
    Forum Contributor mongoose36's Avatar
    Join Date
    06-10-2013
    Location
    Lincoln
    MS-Off Ver
    Excel 2013
    Posts
    389

    Re: Numeric code in textbox

    Here is a system I use. It evaluates each key stroke as the user types it in. If the key stroke is a number then nothing happens, but if the keystroke is a letter or it will remove give an error message and remove the keystroke.

    I have created an example code for a UserFrom with two textboxes...you can incorporate into your code.

    To test create a UserForm with two textboxes named TextBox1 and TextBox2 and copy and paste the following code into it.

    Please Login or Register  to view this content.
    If your questions has been answered to your satisfaction please don't forget to do the following:

    Add Reputation ... and ... Mark Thread as Solved

    Thanks,

    Ma 10:8b Freely you have received; freely give.

  3. #3
    Registered User
    Join Date
    05-06-2012
    Location
    Lisbon,Portugal
    MS-Off Ver
    Excel 2010
    Posts
    79

    Re: Numeric code in textbox

    Hello,Cplettner,
    Thank you for your answer.
    Nice, it works, but is it possible to join all textboxes in just one code? That´s because I have an userform with 30 textboxes, and so, the code would be very large.
    Sorry for insist, I'd be very grateful

  4. #4
    Forum Contributor mongoose36's Avatar
    Join Date
    06-10-2013
    Location
    Lincoln
    MS-Off Ver
    Excel 2013
    Posts
    389

    Re: Numeric code in textbox

    This is the most that can be done...unfortunately you will need a separate change event for all text boxes there is no way around that to my knowledge.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    05-06-2012
    Location
    Lisbon,Portugal
    MS-Off Ver
    Excel 2010
    Posts
    79

    Re: Numeric code in textbox

    Hello cplettner
    Tankyou very much, it works very well. Thank again
    Carlos

  6. #6
    Forum Contributor mongoose36's Avatar
    Join Date
    06-10-2013
    Location
    Lincoln
    MS-Off Ver
    Excel 2013
    Posts
    389

    Re: Numeric code in textbox

    You are welcome!
    Please Add Reputation if you are satisfied and mark the thread as "Solved"

  7. #7
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Numeric code in textbox

    Hi jdasp49

    You can do this by introducing a Class Module
    is it possible to join all textboxes in just one code
    See attached for an example.
    Attached Files Attached Files
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  8. #8
    Forum Contributor mongoose36's Avatar
    Join Date
    06-10-2013
    Location
    Lincoln
    MS-Off Ver
    Excel 2013
    Posts
    389

    Re: Numeric code in textbox

    Awesome @jaslake! Thanks for the tip!

  9. #9
    Forum Contributor mongoose36's Avatar
    Join Date
    06-10-2013
    Location
    Lincoln
    MS-Off Ver
    Excel 2013
    Posts
    389

    Re: Numeric code in textbox

    Based on a request by @YasserKahlil...to only allow one period (".") in the text box
    Change
    Please Login or Register  to view this content.
    To
    Please Login or Register  to view this content.
    I think

  10. #10
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Numeric code in textbox

    @YasserKahlil

    Play with this in the Class Module...there's a better way but I'm using the OP's Code...

    Please Login or Register  to view this content.

+ 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. Format TextBox Numeric value only
    By onmyway in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-27-2015, 03:56 AM
  2. [SOLVED] VBA code for assigning a numeric code to text; then numeric code populates table
    By cteaster in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-14-2014, 08:01 PM
  3. [SOLVED] VBA Code for Textbox: First 3 characters Alphabets next 3 characters numeric
    By honger in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-11-2013, 01:05 AM
  4. Multiplying a numeric value textbox by a duration value textbox
    By chrisjames25 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-01-2013, 05:05 AM
  5. Numeric Textbox Properties
    By puuts in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-09-2013, 08:31 AM
  6. Numeric Values in a textbox
    By GogsJames in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-20-2006, 01:18 AM
  7. [SOLVED] Format Numeric data in Textbox
    By stickandrock in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-24-2005, 09:05 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