Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Disable autoformat of "true" and "false" text | Excel Discussion (Misc queries) | |||
Check if cells contain the word "Thailand", return "TRUE" | Excel Worksheet Functions | |||
change "true" and "false" to "availble" and "out of stock" | Excel Worksheet Functions | |||
Typing "true" excel 2007 change it to "TRUE" | Excel Discussion (Misc queries) | |||
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next | New Users to Excel |