ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Application.ScreenUpdating problem (https://www.excelbanter.com/excel-programming/320628-application-screenupdating-problem.html)

jkitzy

Application.ScreenUpdating problem
 
Help!
Can't quite figure out why, but this code doesn't stop the screen from
updating. As it cycles through the For statement, the screen's updating.



Private Sub Workbook_Open()
Dim sh As Worksheet

Application.ScreenUpdating = False

For Each sh In ThisWorkbook.Worksheets
sh.Protect "unlock", , , userinterfaceonly:=True
sh.EnableSelection = xlUnlockedCells
Next sh

Worksheets("DataWorksheet").Visible = False
Worksheets("Information").Activate

'set page up for display
GoToForm

Application.ScreenUpdating = True

End Sub

gocush[_29_]

Application.ScreenUpdating problem
 
I ran your code and found no screen updating during the run.
However, I was not able to select ANY cells including the unlocked ones.
since your code enables selection AFTER you have locked the sheets.

Moving sh.EnableSelection = xlUnlockedCells
to before the protect command solves this problem.

"jkitzy" wrote:

Help!
Can't quite figure out why, but this code doesn't stop the screen from
updating. As it cycles through the For statement, the screen's updating.



Private Sub Workbook_Open()
Dim sh As Worksheet

Application.ScreenUpdating = False

For Each sh In ThisWorkbook.Worksheets
sh.Protect "unlock", , , userinterfaceonly:=True
sh.EnableSelection = xlUnlockedCells
Next sh

Worksheets("DataWorksheet").Visible = False
Worksheets("Information").Activate

'set page up for display
GoToForm

Application.ScreenUpdating = True

End Sub


jkitzy

Application.ScreenUpdating problem
 
Thanks go. That helped with another problem I was having. I think I may have
found my screen updating problem, too.

I have a sheet_deactivate event on my first page that activates other sheets
and does stuff. I think what was happening was that as those sheets were
activating, they were changing the screenupdating to True. How? Dunno. But, I
put code in that allows me to check to see if the sheet_activate event comes
from another macro and then doesn't perform the sheet_activate event if it
does. Make sense?

"gocush" wrote:

I ran your code and found no screen updating during the run.
However, I was not able to select ANY cells including the unlocked ones.
since your code enables selection AFTER you have locked the sheets.

Moving sh.EnableSelection = xlUnlockedCells
to before the protect command solves this problem.



gocush[_29_]

Application.ScreenUpdating problem
 
Happens to me all the time til I insert
Application.EnableEvents=True
to turn off object change events out of the loop temporarily
then reverse the above code.

"jkitzy" wrote:

Thanks go. That helped with another problem I was having. I think I may have
found my screen updating problem, too.

I have a sheet_deactivate event on my first page that activates other sheets
and does stuff. I think what was happening was that as those sheets were
activating, they were changing the screenupdating to True. How? Dunno. But, I
put code in that allows me to check to see if the sheet_activate event comes
from another macro and then doesn't perform the sheet_activate event if it
does. Make sense?

"gocush" wrote:

I ran your code and found no screen updating during the run.
However, I was not able to select ANY cells including the unlocked ones.
since your code enables selection AFTER you have locked the sheets.

Moving sh.EnableSelection = xlUnlockedCells
to before the protect command solves this problem.




All times are GMT +1. The time now is 08:49 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com