Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
worksheet_calculate | Excel Programming | |||
Worksheet_Calculate | Excel Programming | |||
worksheet_calculate | Excel Discussion (Misc queries) | |||
Worksheet_calculate() | Excel Programming | |||
worksheet_calculate **help** | Excel Programming |