+ Reply to Thread
Results 1 to 5 of 5

Input Box

  1. #1
    Registered User
    Join Date
    01-20-2014
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    59

    Input Box

    I have the following code that requires the user to input a number between 1 and 3. When the users clicks 'Cancel', the box stays open, until a valid number is entered. How would I adapt this, to allow the user to click cancel and return the cursor to the same cell it was in? Furthermore, how would I be able to adapt it to perhaps display a message box if the user entered an invalid number, and then return the user to the input box?

    The code is:

    Again:
    cods = InputBox("How many attempts did this take?", "Attempts")
    'Check valid number
    If Not IsNumeric(Val(cods)) Then GoTo Again
    If Not Val(cods) > 0 Then GoTo Again
    If Not Val(cods) < 4 Then GoTo Again
    Thanks in advance

  2. #2
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Input Box

    You can dimension cods as a variant ten use something like :-

    Please Login or Register  to view this content.
    Elegant Simplicity............. Not Always

  3. #3
    Registered User
    Join Date
    01-20-2014
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    59

    Re: Input Box

    Quote Originally Posted by AndyLitch View Post
    You can dimension cods as a variant ten use something like :-

    Please Login or Register  to view this content.
    Thanks for your reply, however that doesn't seem to work either. Just keeps prompting for an input as before

  4. #4
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Input Box

    Sorry 'bout that... .. Try this

    Please Login or Register  to view this content.
    Last edited by AndyLitch; 04-09-2014 at 07:53 AM.

  5. #5
    Registered User
    Join Date
    01-20-2014
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    59

    Re: Input Box

    Quote Originally Posted by AndyLitch View Post
    Sorry 'bout that... .. Try this

    Please Login or Register  to view this content.
    thanks for that

+ 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. Data Input Form with number of line items based on user input
    By j_gideon in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-25-2013, 02:54 PM
  2. [SOLVED] input date column A, increment B, select blank cell in D and input time. in a macro
    By jeffstu in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-19-2012, 11:19 AM
  3. [SOLVED] Macro to manually input which field (column) to autofilter on using an input prompt
    By rin in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-21-2012, 09:35 AM
  4. Automatic Formula Input Based on User Input Using a Macro
    By Drayloc in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-03-2012, 12:10 PM
  5. Using text box input to lookup number and replace based on user input into new column
    By harl3y412 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-28-2011, 03:15 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