Greetings fellow Excel users! Let me first begin by saying that this is my first post on this forum (actually on any forum), so please forgive me if I inadvertently break any rules for making posts. And I would also like to thank you for taking time out to read my post.
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
Now, let me describe the problem I’m having (Windows 7 Ultimate, Excel 2010) by giving you a set up. Take a Workbook with 2 Sheets. Sheet 2 Cell A1 has a formula =Sheet1!A1, EnableCalculation property of Sheet2 to TRUE and in Sheet2 Object there is a Sub
<o></o>
In Module1 there is a SUB<o></o>
Now, enter 1 in Sheet1 Cell A1 – a message box with “Value 1” is displayed. Next, set EnableCalculation property of Sheet2 to FALSE and enter 2 in Sheet1 Cell A1 – nothing happens. Now, run the mySub in Module 1 – Cell A1 on Sheet2 displays 2 and EnableCalculation property of Sheet2 is set to FALSE. So far, so good. Now enter 3 in Sheet1 Cell A1 – a message box with “Value 2” is displayed!
It would seem that during the execution of mySub a Calculation event was fired (even though Application.EnableEvents was set to FALSE) and the value of 2 was stored (where?) and then this event was released when 3 was entered into Cell A1 on Sheet1 (even though EnableCalculation is set to FALSE for Sheet2). Any clue what’s going on here and how to “fix” this strange behaviour?
Many thanks.<o></o>
<o></o>
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
Now, let me describe the problem I’m having (Windows 7 Ultimate, Excel 2010) by giving you a set up. Take a Workbook with 2 Sheets. Sheet 2 Cell A1 has a formula =Sheet1!A1, EnableCalculation property of Sheet2 to TRUE and in Sheet2 Object there is a Sub
<o></o>
Code:
Private Sub Worksheet_Calculate()
i = MsgBox("Value " & Me.Range("A1").Value, vbOKOnly)
End Sub
In Module1 there is a SUB<o></o>
Code:
Public Sub mySub()
Application.EnableEvents = False
ThisWorkbook.Worksheets(2).EnableCalculation = True
ThisWorkbook.Worksheets(2).EnableCalculation = False
Application.EnableEvents = True
End Sub
Now, enter 1 in Sheet1 Cell A1 – a message box with “Value 1” is displayed. Next, set EnableCalculation property of Sheet2 to FALSE and enter 2 in Sheet1 Cell A1 – nothing happens. Now, run the mySub in Module 1 – Cell A1 on Sheet2 displays 2 and EnableCalculation property of Sheet2 is set to FALSE. So far, so good. Now enter 3 in Sheet1 Cell A1 – a message box with “Value 2” is displayed!
It would seem that during the execution of mySub a Calculation event was fired (even though Application.EnableEvents was set to FALSE) and the value of 2 was stored (where?) and then this event was released when 3 was entered into Cell A1 on Sheet1 (even though EnableCalculation is set to FALSE for Sheet2). Any clue what’s going on here and how to “fix” this strange behaviour?
Many thanks.<o></o>
<o></o>