+ Reply to Thread
Results 1 to 6 of 6

Force only numeric to text box not working

  1. #1
    Forum Contributor
    Join Date
    09-20-2012
    Location
    Norge
    MS-Off Ver
    Excel 2007
    Posts
    114

    Force only numeric to text box not working

    Hi,

    I´m trying to force only to allow numeric values to 3 text boxes. The below code is what I can come up with so far by searching the net, but it will not work. Basically it does nothing and if I try to play around with it and change it in any way I just get errors.

    Maybe some VBA genius is able to see what might be the problem in this:

    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor
    Join Date
    07-04-2012
    Location
    Cape Town, RSA
    MS-Off Ver
    Office 365 ProPlus
    Posts
    1,050

    Re: Force only numeric to text box not working

    Hi,

    The code is working fine for me...
    Test the attached workbook and see if it is fine for you?
    Attached Files Attached Files
    Regards,
    Rudi

  3. #3
    Forum Contributor
    Join Date
    09-20-2012
    Location
    Norge
    MS-Off Ver
    Excel 2007
    Posts
    114

    Re: Force only numeric to text box not working

    Hi RudiS,

    It Works indeed in your example file, but for some reason it does not do anything in mine.

    I have no Clue what could be the problem. If i just make a MsgBox upon change of the textbox it Works meaning I´m putting the code in the right Place, but the OnlyNumbers will not kick in if I type letters.

    Can you look at my example here and see if you see the problem?

    Example Not Working.xlsm

    P.S. Upon atrt hit the "Legg til Avtale" button, then Select the optionbutton up in th eright corner "Leasing". Then the textbox "Avtalenummer" is enabled which is the texbox in question.
    By the way, I also tried the onlynumbers on several other texboxes but nothing.

  4. #4
    Valued Forum Contributor
    Join Date
    07-04-2012
    Location
    Cape Town, RSA
    MS-Off Ver
    Office 365 ProPlus
    Posts
    1,050

    Re: Force only numeric to text box not working

    Ah... I was not aware that your text boxes were placed into a frame. This means that to test the values being typed into the text box, you need to reference the frame first. I have attached the corrected workbook...

    The code I updated is as follows:
    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Force only numeric to text box not working

    If you put this code in the userform's code module, the user will only be able to enter numbers into TextBox1.
    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  6. #6
    Forum Contributor
    Join Date
    09-20-2012
    Location
    Norge
    MS-Off Ver
    Excel 2007
    Posts
    114

    Re: Force only numeric to text box not working

    RudiS and mikerickson,

    both solutions work. Thank you so much

    So stupid of me that I didn´t see that it was in a frame. Sometimes you just get completely blinded for the easiest things.

    Will mark this as solved!

+ 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. Force Fill Series with Alpha Numeric Cell Entry
    By HangMan in forum Excel General
    Replies: 17
    Last Post: 02-28-2014, 12:49 PM
  2. Sumif is working for numeric values but can we do the same for text?
    By vinsocf in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-06-2014, 02:59 PM
  3. Sumif is working for numeric values but can we do the same for text?
    By vinsocf in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-06-2014, 08:35 AM
  4. [SOLVED] vba macros to force user to input numeric values for numeric values with hyphen
    By Abdur_rahman in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-28-2013, 01:05 PM
  5. [SOLVED] Howto force numeric locale ?
    By Antoine Cellerier in forum Excel General
    Replies: 0
    Last Post: 01-18-2006, 05:50 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