+ Reply to Thread
Results 1 to 8 of 8

MsgBox problems + reloading script on error

  1. #1
    Registered User
    Join Date
    08-01-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    10

    MsgBox problems + reloading script on error

    Hi,

    I have created an InputBox to get a user input on a certain set of data to appear in a form (sample file attached).

    Problem 1: When InputBox first opens up, there is already a default value of '1', how do I get rid of this?
    Problem 2: When the user input in InputBox doesn't match the data, I'm trying to have a MsgBox to inform them that their entry was invalid, but I keep getting a syntax error.
    Problem 3: In the case that the user does enter an invalid value, how do I reload the form so they can try again?

    Thanks.
    Attached Files Attached Files
    Last edited by OnlyTheSnake; 08-03-2011 at 10:33 PM.

  2. #2
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: MsgBox problems + reloading script on error

    Hi OnlyTheSnake, Try the following code and let me know if it meets your requirements
    Please Login or Register  to view this content.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  3. #3
    Valued Forum Contributor gjlindn's Avatar
    Join Date
    08-01-2011
    Location
    Dodgeville, WI
    MS-Off Ver
    Excel 2003, 2007, 2010, 2013
    Posts
    369

    Smile Re: MsgBox problems + reloading script on error

    Hello OnlyTheSnake. I looked at your code and I think you'd benefit from using the Find function rather than worksheetfunction.match. Here's your code slightly modified.
    Please Login or Register  to view this content.
    -Greg If this is helpful, pls click Star icon in lower left corner

  4. #4
    Valued Forum Contributor gjlindn's Avatar
    Join Date
    08-01-2011
    Location
    Dodgeville, WI
    MS-Off Ver
    Excel 2003, 2007, 2010, 2013
    Posts
    369

    Re: MsgBox problems + reloading script on error

    Sorry Mordred! I should have refreshed before I posted. OnlyTheSnake, Mordred's code should work just fine

  5. #5
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: MsgBox problems + reloading script on error

    No need to be sorry gjlindn. We pretty much did the same thing!

  6. #6
    Registered User
    Join Date
    08-01-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: MsgBox problems + reloading script on error

    I'm always amazed at the speed of responses here. Both sets of codes do exactly what I need, however gjlindn, your code still results in the default value of '1' appearing in the input box.

    Thanks to both of you for replying!

  7. #7
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: MsgBox problems + reloading script on error

    The value of 1 disappeared when I removed vbOkCancel from the input box.

  8. #8
    Valued Forum Contributor gjlindn's Avatar
    Join Date
    08-01-2011
    Location
    Dodgeville, WI
    MS-Off Ver
    Excel 2003, 2007, 2010, 2013
    Posts
    369

    Re: MsgBox problems + reloading script on error

    Ah...yes, the vbOKCancel would result in a 1 since it's in the Default position of the InputBox...I missed that (I think it must have been in the original code). Deleting vbOKCancel would remove the 1 from the default text. Thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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