Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Toggle between True and False confuses me
I want to see the msgbox only once when I first activate the sheet. I
do not want to be bothered again and again. But the msgbox keeps popping up every time I go to the sheet.. What is wrong with the following two codes? Option Explicit Dim ABC Sub Workbook_Open() ABC = False End Sub Sub Worksheet_Activate() If IsNull(ABC) Then ABC = False End If If ABC = False Then MsgBox "Please pay attention to this formula." ABC = True End If End Sub Thanks in advance H.Z. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Toggle between True and False confuses me
On May 12, 10:24*am, Curious wrote:
I want to see the msgbox only once when I first activate the sheet. I do not want to be bothered again and again. But the msgbox keeps popping up every time I go to the sheet.. What is wrong with the following two codes? Option Explicit Dim ABC Sub Workbook_Open() ABC = False End Sub Sub Worksheet_Activate() If IsNull(ABC) Then * * ABC = False End If If ABC = False Then * * MsgBox "Please pay attention to this formula." * * ABC = True End If End Sub Thanks in advance H.Z. H.Z. See below for a solution. As a side note, when a Boolean variable is initialized, it's always FALSE unless you switch it to TRUE. If you switch it to TRUE and want it to be FALSE again, then you have to "force" it to be FALSE. Best, Matthew Herbert Create a module (i.e. Insert | Module) and place the following in the declarations section: Public ABC As Boolean Then place the following in your Worksheet_Activate event: Private Sub Worksheet_Activate() If ABC = False Then MsgBox "Please pay attention to this formula." ABC = True End If End Sub |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Toggle between True and False confuses me
H.Z.,
You're doing too much with the worksheet activate event. Try it this way. Dim ABC As Boolean Sub Workbook_Open() ABC = True End Sub Sub Worksheet_Activate() If ABC Then MsgBox "Please pay attention to this formula." ABC = False End If End Sub HTH, Bernie MS Excel MVP "Curious" wrote in message ... I want to see the msgbox only once when I first activate the sheet. I do not want to be bothered again and again. But the msgbox keeps popping up every time I go to the sheet.. What is wrong with the following two codes? Option Explicit Dim ABC Sub Workbook_Open() ABC = False End Sub Sub Worksheet_Activate() If IsNull(ABC) Then ABC = False End If If ABC = False Then MsgBox "Please pay attention to this formula." ABC = True End If End Sub Thanks in advance H.Z. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Toggle between True and False confuses me
On May 12, 10:39*am, wrote:
On May 12, 10:24*am, Curious wrote: I want to see the msgbox only once when I first activate the sheet. I do not want to be bothered again and again. But the msgbox keeps popping up every time I go to the sheet.. What is wrong with the following two codes? Option Explicit Dim ABC Sub Workbook_Open() ABC = False End Sub Sub Worksheet_Activate() If IsNull(ABC) Then * * ABC = False End If If ABC = False Then * * MsgBox "Please pay attention to this formula." * * ABC = True End If End Sub Thanks in advance H.Z. H.Z. See below for a solution. *As a side note, when a Boolean variable is initialized, it's always FALSE unless you switch it to TRUE. *If you switch it to TRUE and want it to be FALSE again, then you have to "force" it to be FALSE. Best, Matthew Herbert Create a module (i.e. Insert | Module) and place the following in the declarations section: Public ABC As Boolean Then place the following in your Worksheet_Activate event: Private Sub Worksheet_Activate() If ABC = False Then * * MsgBox "Please pay attention to this formula." * * ABC = True End If End Sub- Hide quoted text - - Show quoted text - Thank you Bernie and Matthew for your promp response. Matthew's tip works very well. Two key points worth mentioning: 1. As a side note, when a Boolean variable is initialized, it's always FALSE 2. Create a public variable that will be used by all sheets in this workbook H.Z. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|