+ Reply to Thread
Results 1 to 4 of 4

Vba to exit sub on cancel on inputbox

  1. #1
    Registered User
    Join Date
    12-25-2015
    Location
    GREECE
    MS-Off Ver
    2007
    Posts
    31

    Vba to exit sub on cancel on inputbox

    I have a macro to copy a template and rename the new sheet after what user puts in inputbox.
    If you put nothing and press OK or if you press Cancel I get error: application defined or object defined error.

    What I would like is: if you put in nothing and press OK or if you press Cancel to exit sub and of course delete the sheet it copied and maybe a msg that nothing happened.
    I tried if ... "false" and some other stuff but nothing worked.

    This is my code:

    Please Login or Register  to view this content.
    Thank you.

  2. #2
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Vba to exit sub on cancel on inputbox

    Hi,

    I would suggest validating the input first
    Please Login or Register  to view this content.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  3. #3
    Registered User
    Join Date
    12-25-2015
    Location
    GREECE
    MS-Off Ver
    2007
    Posts
    31

    Re: Vba to exit sub on cancel on inputbox

    Thank you very much, it works.

  4. #4
    Registered User
    Join Date
    12-25-2015
    Location
    GREECE
    MS-Off Ver
    2007
    Posts
    31

    Re: Vba to exit sub on cancel on inputbox

    I put in my msgbox as well.

    Please Login or Register  to view this content.

+ 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] MACRO: If user clicks cancel in inputbox,then do nothing. Problem with inputbox appearance
    By Tona in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-05-2015, 04:33 AM
  2. [SOLVED] Exit Sub if Inputbox cancel, X Button or blank value is used (bypass debug)
    By liamtimms1985 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-18-2015, 07:03 AM
  3. Inputbox - formatted as Date, unable to exit sub on Cancel
    By Lewis Smeby in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-23-2015, 05:27 PM
  4. [SOLVED] Exit Sub on InputBox Cancel
    By qwerty7 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-01-2015, 07:33 PM
  5. [SOLVED] If Cancel on Input Box, exit sub
    By guitarsweety in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-28-2014, 07:24 PM
  6. When Cancel is selected, I want to exit sub
    By Rubert in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-20-2014, 05:02 PM
  7. Exit Sub when I hit cancel
    By erock24 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-20-2007, 01:27 PM

Tags for this Thread

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