+ Reply to Thread
Results 1 to 2 of 2

InputBox - Cancel

  1. #1
    Registered User
    Join Date

    InputBox - Cancel

    This seems like it should be a simple enough solution, but for the life of me I can't seem to figure it out. I have an InputBox presenting the user with a question. Everything runs fine- unless the user decides to back out and hit the cancel button. It goes into Debug, and I can imagine what the problem is... just can't figure out how to exit the sub. This is simple enough with a MsgBox, but I can't figure out the method for the InputBox.
    Any Input is greatly appreciated. (No pun intended)

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Hello Lonwez,

    The value returned by the InputBox will be an empty string. Check if the returned value is an empty string and exit it the Sub if true.

    RetVal = InputBox("Input some data and Click OK")
    If RetVal = "" Then Exit Sub

    This is discussed fully in the VBA On-Line help that comes with Office. To activate the Visual Basic Editor, press Alt + F8 keys together. Go to Help on the Toolbar and enter InputBox.

    Leith Ross

+ Reply to Thread

Thread Information

Users Browsing this Thread

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


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