Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default event handler for calculation

How do i intercept a change in Application.Calculation
I have a checkbox on a worksheet that says "Automatic Calculation" i want
it to be updated each time the calculation changes from automatic to manual.
if manual then unchecked, if automatic, then checked.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default event handler for calculation

There's no event that detects a change in option settings.

You could use other events to set the checkbox whenever they fire, e.g.:

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
UpdateCheckbox
End Sub

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
UpdateCheckbox
End Sub

Private Sub UpdateCheckbox()
Sheets("Sheet1").CheckBoxes("Check Box 1").Value = _
Application.Calculation = xlCalculationAutomatic
End Sub


But that won't guarantee the value's updated at any particular time.

You could use an OnTime macro to update every few seconds:

In the ThisWorkbook code module:

Private Sub Workbook_Open()
UpdateCheckbox bStart:=True
End Sub

In a regular code module:

Public Sub UpdateCheckbox(Optional bStart As Boolean = False)
Const cnSeconds As Long = 5
Static cb As CheckBox
Static nLast As Long
Dim nCalc As Long

If bStart Then
Set cb = Sheets("Sheet1").CheckBoxes("Check Box 1")
nLast = 0
End If
nCalc = Application.Calculation
If nCalc < nLast Then
cb.Value = (nCalc = xlCalculationAutomatic)
nLast = nCalc
End If
Application.OnTime _
EarliestTime:=Now + TimeSerial(0, 0, cnSeconds), _
Procedu="UpdateCheckbox", _
Schedule:=True
End Sub


In article ,
Spencer Hutton wrote:

How do i intercept a change in Application.Calculation
I have a checkbox on a worksheet that says "Automatic Calculation" i want
it to be updated each time the calculation changes from automatic to manual.
if manual then unchecked, if automatic, then checked.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default event handler for calculation

thanks, thats what i had done, i just wasnt sure if ther ewas another way.
thank you.

"JE McGimpsey" wrote:

There's no event that detects a change in option settings.

You could use other events to set the checkbox whenever they fire, e.g.:

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
UpdateCheckbox
End Sub

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
UpdateCheckbox
End Sub

Private Sub UpdateCheckbox()
Sheets("Sheet1").CheckBoxes("Check Box 1").Value = _
Application.Calculation = xlCalculationAutomatic
End Sub


But that won't guarantee the value's updated at any particular time.

You could use an OnTime macro to update every few seconds:

In the ThisWorkbook code module:

Private Sub Workbook_Open()
UpdateCheckbox bStart:=True
End Sub

In a regular code module:

Public Sub UpdateCheckbox(Optional bStart As Boolean = False)
Const cnSeconds As Long = 5
Static cb As CheckBox
Static nLast As Long
Dim nCalc As Long

If bStart Then
Set cb = Sheets("Sheet1").CheckBoxes("Check Box 1")
nLast = 0
End If
nCalc = Application.Calculation
If nCalc < nLast Then
cb.Value = (nCalc = xlCalculationAutomatic)
nLast = nCalc
End If
Application.OnTime _
EarliestTime:=Now + TimeSerial(0, 0, cnSeconds), _
Procedu="UpdateCheckbox", _
Schedule:=True
End Sub


In article ,
Spencer Hutton wrote:

How do i intercept a change in Application.Calculation
I have a checkbox on a worksheet that says "Automatic Calculation" i want
it to be updated each time the calculation changes from automatic to manual.
if manual then unchecked, if automatic, then checked.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default event handler for calculation

Then thanks a *whole* lot for wasting my time....


In article ,
Spencer Hutton wrote:

thanks, thats what i had done, i just wasnt sure if ther ewas another way.
thank you.

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
Centralized event handler Nayan Excel Programming 1 November 2nd 07 07:25 PM
Event handler VBA Noob[_4_] Excel Programming 4 April 26th 06 03:49 PM
Clipboard Event Handler? [email protected] Excel Programming 1 April 2nd 06 04:37 AM
Event handler in a cell Man Utd Excel Programming 3 June 15th 05 07:44 AM
where is the workbook_open event handler??? Steff_DK[_10_] Excel Programming 2 April 25th 04 02:43 PM


All times are GMT +1. The time now is 12:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"