Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default EnableEvents doesn't work

Hi All,

I have a checkbox with a CheckBox_Click event. In some cases I want to
change the value of its linked cell (to FALSE) through VBA, and in these
cases I don't want to run CheckBox_Click event code. I set
Application.EnableEvents to FALSE before changing the linked cell value, but
event code is still executed. How can I avoid it?

Thanks,
Stefi

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default EnableEvents doesn't work

Or how can I differentiate real click and changing linked cell value with VBA?
Stefi


€˛Stefi€¯ ezt Ć*rta:

Hi All,

I have a checkbox with a CheckBox_Click event. In some cases I want to
change the value of its linked cell (to FALSE) through VBA, and in these
cases I don't want to run CheckBox_Click event code. I set
Application.EnableEvents to FALSE before changing the linked cell value, but
event code is still executed. How can I avoid it?

Thanks,
Stefi

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default EnableEvents doesn't work

Hi Stefi,

EnableEvents does not work with these controls.

Try using a boolean variable, For example try
something like:

'=============
Private Sub CheckBox1_Click()
If Not blStop Then
'Do something, e.g.:
MsgBox "Hi"
End If
End Sub
'<<=============


In a standard module:
'=============
Public blStop As Boolean

Option Explicit

Public Sub Tester()
blStop = True
ActiveSheet.OLEObjects("CheckBox1").Object.Value = xlOn

End Sub
'<<=============

---
Regards,
Norman



"Stefi" wrote in message
...
Hi All,

I have a checkbox with a CheckBox_Click event. In some cases I want to
change the value of its linked cell (to FALSE) through VBA, and in these
cases I don't want to run CheckBox_Click event code. I set
Application.EnableEvents to FALSE before changing the linked cell value,
but
event code is still executed. How can I avoid it?

Thanks,
Stefi



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default EnableEvents doesn't work

Hi Stefi,

'--------------
Public blStop As Boolean

Option Explicit

'--------------


Was intended as


--
---
Regards,
Norman



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default EnableEvents doesn't work

Hi Stefi,

'--------------
Public blStop As Boolean

Option Explicit

'--------------


Was intended as

Option Explicit
Public blStop As Boolean

---
Regards,
Norman




"Norman Jones" wrote in message
...
Hi Stefi,

EnableEvents does not work with these controls.

Try using a boolean variable, For example try
something like:

'=============
Private Sub CheckBox1_Click()
If Not blStop Then
'Do something, e.g.:
MsgBox "Hi"
End If
End Sub
'<<=============


In a standard module:
'=============
Public blStop As Boolean

Option Explicit

Public Sub Tester()
blStop = True
ActiveSheet.OLEObjects("CheckBox1").Object.Value = xlOn

End Sub
'<<=============

---
Regards,
Norman



"Stefi" wrote in message
...
Hi All,

I have a checkbox with a CheckBox_Click event. In some cases I want to
change the value of its linked cell (to FALSE) through VBA, and in these
cases I don't want to run CheckBox_Click event code. I set
Application.EnableEvents to FALSE before changing the linked cell value,
but
event code is still executed. How can I avoid it?

Thanks,
Stefi







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default EnableEvents doesn't work

This isn't an event to excel. So you have to take care of it yourself.

Are these controls from the control toolbox toolbar placed on a worksheet?

If you're calling the _click event from a procedure in a general module, you can
use:

Option Explicit
Public blkproc As Boolean
Sub testme()
blkproc = True
Sheet1.CheckBox1.Value = False
blkproc = False
End Sub

Then in the worksheet module:
Option Explicit
Private Sub CheckBox1_Change()
If blkproc = True Then Exit Sub
MsgBox "Change"
End Sub
Private Sub CheckBox1_Click()
If blkproc = True Then Exit Sub
MsgBox "Click"
End Sub

(I usually use _change.)




Stefi wrote:

Hi All,

I have a checkbox with a CheckBox_Click event. In some cases I want to
change the value of its linked cell (to FALSE) through VBA, and in these
cases I don't want to run CheckBox_Click event code. I set
Application.EnableEvents to FALSE before changing the linked cell value, but
event code is still executed. How can I avoid it?

Thanks,
Stefi


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default EnableEvents doesn't work

Many thanks, Dave and Norman for your quick responses, I'll try that way!
Stefi


€˛Dave Peterson€¯ ezt Ć*rta:

This isn't an event to excel. So you have to take care of it yourself.

Are these controls from the control toolbox toolbar placed on a worksheet?

If you're calling the _click event from a procedure in a general module, you can
use:

Option Explicit
Public blkproc As Boolean
Sub testme()
blkproc = True
Sheet1.CheckBox1.Value = False
blkproc = False
End Sub

Then in the worksheet module:
Option Explicit
Private Sub CheckBox1_Change()
If blkproc = True Then Exit Sub
MsgBox "Change"
End Sub
Private Sub CheckBox1_Click()
If blkproc = True Then Exit Sub
MsgBox "Click"
End Sub

(I usually use _change.)




Stefi wrote:

Hi All,

I have a checkbox with a CheckBox_Click event. In some cases I want to
change the value of its linked cell (to FALSE) through VBA, and in these
cases I don't want to run CheckBox_Click event code. I set
Application.EnableEvents to FALSE before changing the linked cell value, but
event code is still executed. How can I avoid it?

Thanks,
Stefi


--

Dave Peterson

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default EnableEvents doesn't work

Now it works nicely, thanks!
Stefi


€˛Stefi€¯ ezt Ć*rta:

Many thanks, Dave and Norman for your quick responses, I'll try that way!
Stefi


€˛Dave Peterson€¯ ezt Ć*rta:

This isn't an event to excel. So you have to take care of it yourself.

Are these controls from the control toolbox toolbar placed on a worksheet?

If you're calling the _click event from a procedure in a general module, you can
use:

Option Explicit
Public blkproc As Boolean
Sub testme()
blkproc = True
Sheet1.CheckBox1.Value = False
blkproc = False
End Sub

Then in the worksheet module:
Option Explicit
Private Sub CheckBox1_Change()
If blkproc = True Then Exit Sub
MsgBox "Change"
End Sub
Private Sub CheckBox1_Click()
If blkproc = True Then Exit Sub
MsgBox "Click"
End Sub

(I usually use _change.)




Stefi wrote:

Hi All,

I have a checkbox with a CheckBox_Click event. In some cases I want to
change the value of its linked cell (to FALSE) through VBA, and in these
cases I don't want to run CheckBox_Click event code. I set
Application.EnableEvents to FALSE before changing the linked cell value, but
event code is still executed. How can I avoid it?

Thanks,
Stefi


--

Dave Peterson

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
Application.EnableEvents DCPan Excel Worksheet Functions 3 October 18th 08 05:46 AM
EnableEvents BeforeClose Stefi Excel Programming 2 November 16th 05 09:22 AM
application.EnableEvents nc Excel Discussion (Misc queries) 1 September 28th 05 04:00 PM
EnableEvents=False doesn't work? or does it? Intellihome[_30_] Excel Programming 0 June 25th 05 05:29 PM
application.enableEvents jeffP Excel Programming 1 August 1st 04 03:12 PM


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