+ Reply to Thread
Results 1 to 4 of 4

inputbox cancel

  1. #1
    Registered User
    Join Date
    10-07-2011
    Location
    Netherlands
    MS-Off Ver
    2003 (office XP)
    Posts
    19

    inputbox cancel

    Hi people of excelforum.

    I stuck here in my inputbox, and can't seem to find an solution for the cancel button. I already tried dozens of options and it's not getting me any where.
    The problem i have might be simple to some of you.

    As soon as i use my macro I can't use the cancel button, I have to continue the whole thing to finish it. If i use the cancel button it simply give me an error in return, and after that the macro is being aborted.

    The code I am using is for my monthly payments, and by activating an macro it copy's al relevant data to a new sheet with the inputbox to fill in the new sheet name.

    The Code I use,

    Please Login or Register  to view this content.

    Regards Olaf.
    Last edited by alansidman; 11-25-2013 at 08:54 PM. Reason: code tags

  2. #2
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: inputbox cancel

    Hi,

    Please use code tags when posting code. This is rule 3 of the Forum Rules.

    As for your problem:
    Pressing the Cancel button on the InputBox will return a value of "" (empty string) to the variable "newname", which you are then using to assign to a worksheet name (which you obviously can't give a worksheet no name).

    So all you need to do is check if newname has a value of "" before assigning it to the worksheet name, and exit the subroutine if it is.

    Hope this helps

  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,870

    Re: inputbox cancel

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (I have added them for you today. Please read all forum rules and comply in the future.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  4. #4
    Registered User
    Join Date
    10-07-2011
    Location
    Netherlands
    MS-Off Ver
    2003 (office XP)
    Posts
    19

    Re: inputbox cancel

    First of al, thanks for the update to the forum rule's. I just forgot them, i signed up long time ago and yesterday i started to use the forum, my mistake.

    For the code, thanks to. I tried the part already couple of time's but it came up with an compile error or with an copy'd sheet. I placed the "simple line" in diverent spot and it works just great. Thanks for that.

    The code is now like.
    Please Login or Register  to view this content.
    Again many thanks, Olaf.

+ 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. InputBox and Cancel
    By michaelaindia in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-24-2012, 04:32 AM
  2. [SOLVED] Cancel my Inputbox
    By nickmax1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-21-2012, 11:05 AM
  3. Cancel on Inputbox not work
    By unley in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-30-2011, 07:59 PM
  4. InputBox: Cancel/X properties
    By Rick_Stanich in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-08-2009, 04:47 PM
  5. InputBox - Cancel
    By Lonwez in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-06-2005, 07:17 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