Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 135
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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
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
What's the best way to toggle between true and false in Excel? Hiall, My excel work involves a lot of toggling between true and false (booleantypes) ... and it's very repetitive... Is there a way to select a bunch ofcells, and press a key short-cu LunaMoon Excel Discussion (Misc queries) 9 July 29th 08 12:28 AM
What's the best way to toggle between true and false in Excel? Hiall, My excel work involves a lot of toggling between true and false (booleantypes) ... and it's very repetitive... Is there a way to select a bunch ofcells, and press a key short-cu LunaMoon Excel Programming 9 July 29th 08 12:28 AM
Function to return True/False if all are validated as True by ISNU Tetsuya Oguma Excel Worksheet Functions 2 March 15th 06 10:28 AM
Checkbox toggle true/false Donkin Excel Programming 3 June 2nd 05 09:37 AM
Toggle True/False in a cell Dave Peterson[_3_] Excel Programming 2 October 10th 03 03:05 AM


All times are GMT +1. The time now is 07:13 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"