Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default What is "Cancel=True"?

Apologies if this is a simplistic question, but in order to help m
understanding of the macros that Ive been butchering and then addin
together, like a poor mans' Dr Frankenstein, I wondered what thi
meant.

Cancel = True (and indeed Cancel = False) statements are littere
across some macros that I am using, before and after functions, an
dialogue boxes.

I wonder if anyone could explain how this actually works and what i
refers to, and when it should be used?

Many thanks for everybodies continued understanding & patience,
E

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default What is "Cancel=True"?

Ed,

In this case, Cancel would be a Boolean (True or False) argument. It usually
pertains to event code and the Cancel argument allows the event to be
cancelled. So by setting Cancel to True, that event gets cancelled.

An example is this

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)

If Range("A1") = "" Then
MsgBox "Must enter value"
Cancel = True
End If

End Sub

This code is invoked if the workbook save button is invoked. It tests A1 for
data, and if there is none, displays a message, and sets the Cancel
argument. Net effect, the workbook deosn't get saved, as the event is
cancelled.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"universal " wrote in message
...
Apologies if this is a simplistic question, but in order to help my
understanding of the macros that Ive been butchering and then adding
together, like a poor mans' Dr Frankenstein, I wondered what this
meant.

Cancel = True (and indeed Cancel = False) statements are littered
across some macros that I am using, before and after functions, and
dialogue boxes.

I wonder if anyone could explain how this actually works and what it
refers to, and when it should be used?

Many thanks for everybodies continued understanding & patience,
Ed


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default What is "Cancel=True"?

1. Look up 'Cancel Property' in VB Editor help.
2. It is also used in worksheet/workbook event subroutines eg
BeforeSave to stop the process (in this case Save) occurring

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default What is "Cancel=True"?

Hi,
No idea - you will have to post an example macro. One possibility is
that a public variable called Cancel has been declared at the top of a
code module, so that it doesn't appear as a dim statement in the sub.
Another possibility is that the coder has not used Option Explicit at
the top of a module, so that this is a sub level variable. Yet another
possibility is that it says .Cancel = True (note the dot), and then
you proably have a Public variable declared in the code module behind
a Userform..
Impossible to say - post some code.

regards
Paul

universal wrote in message ...
Apologies if this is a simplistic question, but in order to help my
understanding of the macros that Ive been butchering and then adding
together, like a poor mans' Dr Frankenstein, I wondered what this
meant.

Cancel = True (and indeed Cancel = False) statements are littered
across some macros that I am using, before and after functions, and
dialogue boxes.

I wonder if anyone could explain how this actually works and what it
refers to, and when it should be used?

Many thanks for everybodies continued understanding & patience,
Ed


---
Message posted from http://www.ExcelForum.com/

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Disable autoformat of "true" and "false" text drs207 Excel Discussion (Misc queries) 6 April 14th 23 05:33 PM
Check if cells contain the word "Thailand", return "TRUE" ali Excel Worksheet Functions 7 September 14th 07 09:53 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
Typing "true" excel 2007 change it to "TRUE" Mr. T Excel Discussion (Misc queries) 2 April 11th 07 01:24 PM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM


All times are GMT +1. The time now is 10:59 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"