+ Reply to Thread
Results 1 to 3 of 3

Cancel as Boolean argument

  1. #1
    Forum Contributor
    Join Date
    01-28-2008
    MS-Off Ver
    Excel 365
    Posts
    156

    Cancel as Boolean argument

    When I create a worksheet event sub "BeforeDoubleClick", I get the following stub:

    Please Login or Register  to view this content.
    I know what the argument "Target" is, but I don't know when I would ever use the second argument, "Cancel"?

    Any ideas on this?

    Thank you in advance

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Cancel as Boolean argument

    Hi Larry,

    Excellent question.

    You use 'Cancel = True' when you don't want the focus to remain in the cell that was double clicked. This is usually the case when you take some affirmative action based on the 'Double Click' event.

    To see how this works, put 'Cancel = True' in an empty Worksheet_BeforeDoubleClick() macro. Notice how the focus is NOT on the cell that was 'Double Clicked'. Now remove the 'Cancel = True' and notice how the focus IS on the cell that was 'Double Clicked'.

    Lewis

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

    Re: Cancel as Boolean argument

    Cancel is used to, well, cancel the double click action.

    When you double click a cell Excel moves into edit mode, by setting Cancel = True you cancel that.
    If posting code please use code tags, see here.

+ 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] Cancel As Boolean Help
    By Kiotofl in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-25-2014, 11:26 AM
  2. [SOLVED] Private Sub Workbook_BeforePrint(Cancel As Boolean) Range Issue (2007)
    By Excelnoub in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 06-16-2014, 10:31 AM
  3. Workbook_BeforeClose(cancel As Boolean)
    By Vdogeek in forum Excel General
    Replies: 3
    Last Post: 05-23-2014, 12:39 PM
  4. Private Sub Workbook_BeforePrint(Cancel As Boolean) not executing procedures
    By Burrswood in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-10-2013, 11:48 AM
  5. Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) problem
    By 2funny4words in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-29-2009, 07:28 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