+ Reply to Thread
Results 1 to 14 of 14

cancel button Application.Inputbox

  1. #1
    Forum Contributor
    Join Date
    06-21-2013
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    186

    cancel button Application.Inputbox

    Gurus,

    I have a macro that uses an Application.InputBox. All works well, thanks to users of this forum, except when the user selects Cancel on the input box. I am looking for the code to exit the macro when the cancel button is selected.

    Looking through the forum, I have added the BOLD lines but I just don't know enough about VB as to what to define the strButton to. Or even if I am doing this correctly.

    Can someone guide me?

    TIA,
    Tim

    Please Login or Register  to view this content.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: cancel button Application.Inputbox

    Try this.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    06-21-2013
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    186

    Re: cancel button Application.Inputbox

    Norie,

    Unless I am placing the code in the wrong area, it doesn't seem to work.

    Tim

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: cancel button Application.Inputbox

    Where are you placing it and how is it not working?

    It should basically replace this part of your code.
    Please Login or Register  to view this content.
    Oh, and you could remove strButton and this.
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    06-21-2013
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    186

    Re: cancel button Application.Inputbox

    Norie,

    Here is the revised code.
    Please Login or Register  to view this content.
    It errors out at

    Please Login or Register  to view this content.

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: cancel button Application.Inputbox

    What's the error message?

    Also, what level to do have Error trapping set at?

    You can find that out by going to the General tab under Tools>Options... in the VBE.

  7. #7
    Forum Contributor
    Join Date
    06-21-2013
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    186

    Re: cancel button Application.Inputbox

    Norie,

    Sorry, I meant to supply the error message before. The macro is selecting a picture (object) and asking where to place it on a different excel sheet.

    The error is
    error.jpg

    and the options are
    VBoptions.jpg


    Thanks.

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: cancel button Application.Inputbox

    This line is actually supposed to check if Rng is an object, if Rng isn't an object then the sub should be exited?

    Please Login or Register  to view this content.
    Is the error definitely on this line?

  9. #9
    Forum Contributor
    Join Date
    06-21-2013
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    186

    Re: cancel button Application.Inputbox

    when I select debug this is where is stops

    debug.jpg

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: cancel button Application.Inputbox

    Can you upload an example workbook?

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

  11. #11
    Forum Contributor
    Join Date
    06-21-2013
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    186

    Re: cancel button Application.Inputbox

    Norie,

    Here are the files. The one that contains the macro is Master RFQ-V11.xlsm

    MASTER RFQ-V11.xlsm
    MASTER QUOTE LIST - Blank.xlsm

    Please note that the macro being used is Transfer_Info and can be accessed through the button labeled "Send to Master Quote List".

    The macro opens the Master Quote List.xlsm from a specific directory. You will need to change that. I am sure you know this but I wanted to point it out.

    I send you a "blank" Master Quote List" because to file size issues.

    Thanks,
    Tim
    Last edited by TimlmiT; 05-20-2014 at 01:35 PM.

  12. #12
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: cancel button Application.Inputbox

    Try this.
    Please Login or Register  to view this content.
    By the way, what are you actually copying to the other workbook?

    Is it the logo or the logo and some data?

  13. #13
    Forum Contributor
    Join Date
    06-21-2013
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    186

    Re: cancel button Application.Inputbox

    Awesome. that worked.

    the logo is replaced by a picture of a part that is quoted. that picture and some data are transferred to a master list so we can refer back to a quote. Using an object was the only way that I knew how to transfer the picture and data in one click.

    Thanks Again!!!

    Tim

  14. #14
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: cancel button Application.Inputbox

    Actually just realised why you were getting the error.

    For the code I posted you would have to declare Rng at the top of the sub as a Range.
    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] Insert function to 'Cancel' Button in InputBox
    By leleco in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-16-2014, 11:52 AM
  2. [SOLVED] Error when hitting cancel on Application.InputBox
    By wigtown_deano in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-05-2013, 05:26 AM
  3. add cancel button to inputbox
    By SarahPintal in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-03-2011, 02:27 AM
  4. Inputbox cancel button error.
    By abhay_547 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-05-2010, 06:27 AM
  5. activate cancel button in a inputbox
    By mania112 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-19-2009, 07:09 AM

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