+ Reply to Thread
Results 1 to 3 of 3

Only accept integers in a text box with linked spin button

  1. #1
    Forum Contributor
    Join Date
    12-19-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    191

    Only accept integers in a text box with linked spin button

    Hi All,

    I have a linked text box and spin button on a userform so the user can enter text or use the buttons and I'm having trouble barring non-integer inputs! Here's what I have so far:

    Text box = NumberBox
    Spin button= NumberSpin

    Please Login or Register  to view this content.
    Any help would be greatly appreciated. Thanks!

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Only accept integers in a text box with linked spin button

    Didnt we fix this?
    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

  3. #3
    Forum Contributor
    Join Date
    12-19-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    191

    Re: Only accept integers in a text box with linked spin button

    Hi nathansav,

    The code above was from something else I got help with about a month ago, thread here:

    http://www.excelforum.com/excel-prog...ric-input.html

    I'm now working on something different that can only accept integers (whereas the previous application could handle any numerical input).

    I've tried Int() and CInt() to overwrite the text box after all the other conditions have been fulfilled but I can't figure it out.

    Many Thanks

  4. #4
    Registered User
    Join Date
    11-16-2013
    Location
    OK
    MS-Off Ver
    Excel 2013
    Posts
    33

    Re: Only accept integers in a text box with linked spin button

    Assuming you have your global variable called prevvalue already setup in a module, you can use this code to do what you're looking for:

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    12-19-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    191

    Re: Only accept integers in a text box with linked spin button

    ^That's great thanks. I put an extra argument in to reject negative numbers (sorry, forgot to mention that) and it works a treat. Many 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. [SOLVED] Spin Button linked to text box needs to only accept numeric input
    By TPDave in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-13-2014, 09:56 AM
  2. Macro based on Spin Button Linked cell value
    By turist in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-20-2013, 11:57 AM
  3. Spin Button variable linked cell
    By Ozzmatron in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-18-2013, 11:29 PM
  4. [SOLVED] Macro based on Spin Button Linked cell value
    By turist in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-15-2013, 04:07 PM
  5. How to make the spin button's linked cell vary
    By Irascivel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-31-2009, 06:39 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