+ Reply to Thread
Results 1 to 5 of 5

Input Box - Coding Action For Cancel Button

  1. #1
    Forum Contributor
    Join Date
    06-15-2009
    Location
    Ontario, canada
    MS-Off Ver
    Office 365
    Posts
    371

    Input Box - Coding Action For Cancel Button

    I have an input box. When it becomes active, there are two buttons, [OK] and [CANCEL].

    How can I trigger code for pressing the [CANCEL BUTTON]?

    Please Login or Register  to view this content.
    The code doesn't display the message "Cancelled" when the user presses the [CANCEL] button as I had hoped it might.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Input Box - Coding Action For Cancel Button

    Use instead

    Please Login or Register  to view this content.
    Incidentally it's usually good practice to Dim your variables and have an Option Explicit instruction above the Procedure code.

    This forces you to declare variables. Without that you risk mis-spelling a variable in your code which will merrily continue having created a new 'on the fly' variable and you'll get unexpected results.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Input Box - Coding Action For Cancel Button

    Check for length of ui1.

    Ex:
    Please Login or Register  to view this content.
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  4. #4
    Forum Contributor
    Join Date
    06-15-2009
    Location
    Ontario, canada
    MS-Off Ver
    Office 365
    Posts
    371

    Re: Input Box - Coding Action For Cancel Button

    Thank you both for your support! I wouldn't have believed that to have worked since the input box has a default value (alt_alias) in it ... so their is a length and it isn't equal to "". It works, I just can't see the logic.

  5. #5
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Input Box - Coding Action For Cancel Button

    Basically inpubox passes value to variable only when OK is pressed. So, when cancel is hit, the variable remains null.

+ 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. Input box - cancel button
    By jsherwood in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-05-2018, 04:11 PM
  2. [SOLVED] 2 coding question (Input box cancel) & (next i on error match)
    By jp16 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-24-2018, 06:59 AM
  3. [SOLVED] Problem with my cancel button on my input box
    By danbates in forum Excel General
    Replies: 7
    Last Post: 01-23-2017, 06:35 AM
  4. [SOLVED] Input Box Cancel Button
    By underwater24 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-26-2016, 05:08 PM
  5. [SOLVED] Problem with CANCEL button, INPUT BOX
    By GIS2013 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-18-2014, 04:26 PM
  6. [SOLVED] Input box and the cancel button
    By Saturn in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-22-2014, 01:21 PM
  7. Cancel button on input box causes crash
    By EGR2317 in forum Excel General
    Replies: 8
    Last Post: 06-04-2010, 09:51 AM

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