P
Potter
When running a macro that includes a loop with DoEvents alert messages are
not shown to the user. In my case locked cells of protected Worksheets do
not allow data entry but do not alert the user as to why. Even more
problematic the content of these protected cells are delete when the delete
key is pressed! This does not occur if the macro is not running. Instead an
alert dialog is displayed and the action is cancelled.
The problem can be reproduced with the following steps:
1. Create a Workbook and set all cells in a Worksheet to locked
2. Enter values into some of the cells
3. Protect the Worksheet
4. Select a cell and press delete (alert message should be shown)
5. Run a macro with a doevents loop
6. While the loop is running select a cell and press delete (contents are
removed and no alert is shown!)
example macro (runs a doevents loop for 2 minutes):
Sub executeDoEvents()
Application.DisplayAlerts = True
For i = 1 To 1200
Sleep (100)
DoEvents
Next i
MsgBox "Done executing DoEvents"
End Sub
not shown to the user. In my case locked cells of protected Worksheets do
not allow data entry but do not alert the user as to why. Even more
problematic the content of these protected cells are delete when the delete
key is pressed! This does not occur if the macro is not running. Instead an
alert dialog is displayed and the action is cancelled.
The problem can be reproduced with the following steps:
1. Create a Workbook and set all cells in a Worksheet to locked
2. Enter values into some of the cells
3. Protect the Worksheet
4. Select a cell and press delete (alert message should be shown)
5. Run a macro with a doevents loop
6. While the loop is running select a cell and press delete (contents are
removed and no alert is shown!)
example macro (runs a doevents loop for 2 minutes):
Sub executeDoEvents()
Application.DisplayAlerts = True
For i = 1 To 1200
Sleep (100)
DoEvents
Next i
MsgBox "Done executing DoEvents"
End Sub