Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Member
 
Posts: 57
Default Turn off calculate event

Hopefully this is an easy one for you.
I have a worksheet calculate event that works fine until I try to clear the data on my sheet with a macro written to ensure the correct data is deleted as the totals the calculate event uses all #N/A .
Is there code I can put into the macro at the start to disable the calculate event and at the end to re-enable it?
cheers
nobby

Last edited by nobbyknownowt : June 29th 06 at 04:18 PM Reason: cant spell
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default Turn off calculate event

You could turn off events:

application.enableevents = false
'your code
application.enableevents = true

But I would think it would be more usual to just turn calculation to manual, do
the work, and then reset it the way it was.

And there are other things that can slow down your macro, too:

Option Explicit
Sub testme()

Dim CalcMode As Long
Dim ViewMode As Long

Application.ScreenUpdating = False

CalcMode = Application.Calculation
Application.Calculation = xlCalculationManual

ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView

ActiveSheet.DisplayPageBreaks = False

'do the work

'put things back to what they were
Application.Calculation = CalcMode
ActiveWindow.View = ViewMode

End Sub

nobbyknownowt wrote:

Hopefully this is an easy one for you.
I have a worksheet calculate event that works fine until I try to
clear the data on my sheet with a macro written to ensure the correct
data is deleted as the totals the calculate event uses all #N/A .
Is there code I can put into the macro at the start to disable the
calculate event and at the end to re-enable it?
cheers
nobby

--
nobbyknownowt


--

Dave Peterson
  #3   Report Post  
Member
 
Posts: 57
Default

I had a play and went with enable events, thanks

The sheet is designed for other users and I need to keep it a simple as possible

However I have now found a glitch

There are 4 seperate worksheets in te workbook and 4 seperate calculate events. When I activate a worksheet and start completing it a calculate event from another sheet sometimes stalls the program.
How do I make the calculate event sheet specific?


cheers
Nobby

Last edited by nobbyknownowt : July 3rd 06 at 11:10 AM Reason: all went wrong!!
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Turn off calculate event

Calculation is not worksheet specific. It's not even workbook specific. It's
an application setting.

So you can turn calculation to manual and recalc when you want to
(tools|Options|calculation tab|calc now.

=====
But depending on what version of excel you're running, you can actually turn
calculation off for specific worksheets.

worksheets("Sheet1").EnableCalculation = False

IIRC, this was added in xl2002.

But you'll have to turn it back on before calculating--even hitting F9 won't
help.



nobbyknownowt wrote:

I had a play and went with enable events, thanks

The sheet is designed for other users and I need to keep it a simple as
possible

However I have now found a glitch

There are 4 seperate worksheets in te workbook and 4 seperate
calculate events. When I activate a worksheet and start completing it
a calculate event from another sheet sometimes stalls the program.
How do I make the calculate event sheet specific?

cheers
Nobby

--
nobbyknownowt


--

Dave Peterson
  #5   Report Post  
Member
 
Posts: 57
Default

Thanks for the advice Dave
I fixed it by adding an =ISNA formula to ignore the #N/A errors on each sheet then using the "true" resuklt in an =IF to create a 0 or the original formula result then had the calculate event point to this.
Therefore the calculate event can run all the time as when the sheet is not in use the new result 0 will not cause an error.

Thanks again for the direction even though it was that i could not do it the way I wanted without losing automation. At least it sent me off in anoyjer ditrection

Nobby
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
Disable SelectionChange Event BillCPA Excel Discussion (Misc queries) 2 February 17th 06 06:45 PM
Use Excel To Calculate Several ranges within one column Tim H Excel Worksheet Functions 0 January 26th 06 04:11 PM
How can I calculate Vacation Time earned based on length of emplo. Kim Excel Discussion (Misc queries) 2 March 15th 05 08:04 PM
formula to calculate # of days between dates, excluding holidays abs2299 Excel Discussion (Misc queries) 8 March 3rd 05 02:21 AM
Worksheet Row Change event crazybass2 Excel Discussion (Misc queries) 4 December 8th 04 05:29 PM


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