LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default worksheet_calculate

I copied this simple code below from this site recently, to learn more
about vba code. It is my understanding that using worksheet_calculate,
the code should execute automatically upon changes to the worksheet.
But when I change the value in A2, the value in D2 does not change
unless I go to the code in the VBA editor and click on run sub/
userform (or press the F5 key).

I am working in Sheet1, and have the code in Sheet1, so I don't
understand why the code does not execute automatically. Automatic
calculation is set to 'on' (tools/options). I have tried other
worksheet_calculate examples with the same result (no automatic
execution) and I have tried running the program from a different pc
(just to see if I may have inadvertently set some option). I have also
exited the spreadsheet and re-opened, in case enableevents had not
been reset to 'true'.

There is probably a simple explanation, but it's all new to me.

Thanks for any help.

Scott

Private Sub Worksheet_Calculate()
'Must disable events otherwise will run again
'when A2 is saved to D2
Application.EnableEvents = False


If Range("A2") < Range("D2") Then 'Value has changed
Range("d2") = Range("A2") 'Resave new A2 value
End If


Application.EnableEvents = True
End Sub
 
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
worksheet_calculate Libby Excel Programming 1 March 1st 08 03:45 PM
Worksheet_Calculate tmkkoservo Excel Programming 1 August 20th 07 04:08 PM
worksheet_calculate enyaw Excel Discussion (Misc queries) 2 January 26th 07 01:16 PM
Worksheet_calculate() Alex Excel Programming 1 August 30th 05 10:09 PM
worksheet_calculate **help** tommyboy Excel Programming 2 June 29th 04 08:33 AM


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