BruceMutton
Geotechnical
- Sep 4, 2001
- 15
Hi all
I have written a simple user defined function to make it apparent on the worksheet when events are no longer being triggered. (I have an iterative solver type routine that is triggered by the calculate event, rather than using an on sheet button)
In a worksheet cell, I would enter something like;
=IF(bEvents(),"OK","Events are disabled"
It kind of works, in that while VBA code is processing, it gives the results one would expect- ie TRUE when events are enabled, and FALSE when not, however once no code is processing, it returns FALSE regardless of the state of EventsEnabled (as confirmed in the VBE watch window)
What is going on?
Am using Excel 97 SR2
Function Code follows:
Public Function bEvents() As Boolean
'To be used from Worksheet
'Returns state of event enabling as boolean
'Bruce Mutton 25 Sept 2001
Application.Volatile (True)
If Application.EnableEvents Then
bEvents = True
Else
bEvents = False
End If
End Function
I have written a simple user defined function to make it apparent on the worksheet when events are no longer being triggered. (I have an iterative solver type routine that is triggered by the calculate event, rather than using an on sheet button)
In a worksheet cell, I would enter something like;
=IF(bEvents(),"OK","Events are disabled"
It kind of works, in that while VBA code is processing, it gives the results one would expect- ie TRUE when events are enabled, and FALSE when not, however once no code is processing, it returns FALSE regardless of the state of EventsEnabled (as confirmed in the VBE watch window)
What is going on?
Am using Excel 97 SR2
Function Code follows:
Public Function bEvents() As Boolean
'To be used from Worksheet
'Returns state of event enabling as boolean
'Bruce Mutton 25 Sept 2001
Application.Volatile (True)
If Application.EnableEvents Then
bEvents = True
Else
bEvents = False
End If
End Function