[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.excel.programming

ScreenUpdating = False not working

BOBODD

12/14/2006 12:25:00 AM

Im using this code when my workbook opens:
Private Sub Workbook_Open()
Dim i As Integer
For i = 1 To 8
Sheets(i).Visible = xlVeryHidden
Next
Application.ScreenUpdating = False
For Each Worksheet In ThisWorkbook.Worksheets
Worksheet.Visible = xlSheetVisible
Next
ClientDetails.Show
End Sub

The first For loop is only there for testing. Eventually this loop will be
run when the program is closed.

The problem is that although I have the "Application.ScreenUpdating = False"
there, Excel still shows the sheets being unhidden, along with any updates
made. I've checked my entire program, and there are ScreenUpdating = True
statements to change things. What else would cause this?
4 Answers

Corey

12/14/2006 12:34:00 AM

0

you could try moving it down below the : Worksheet.Visible = xlSheetVisible
' line
see if that does anything


"BOBODD" <BOBODD@discussions.microsoft.com> wrote in message
news:BB7E7AEF-524E-43CE-8916-254744C7F6E4@microsoft.com...
> Im using this code when my workbook opens:
> Private Sub Workbook_Open()
> Dim i As Integer
> For i = 1 To 8
> Sheets(i).Visible = xlVeryHidden
> Next
> Application.ScreenUpdating = False
> For Each Worksheet In ThisWorkbook.Worksheets
> Worksheet.Visible = xlSheetVisible
> Next
> ClientDetails.Show
> End Sub
>
> The first For loop is only there for testing. Eventually this loop will be
> run when the program is closed.
>
> The problem is that although I have the "Application.ScreenUpdating =
> False"
> there, Excel still shows the sheets being unhidden, along with any updates
> made. I've checked my entire program, and there are ScreenUpdating = True
> statements to change things. What else would cause this?


Jim Thomlinson

12/14/2006 12:54:00 AM

0

Worksheet is a reserved word... Give this a try...

Private Sub Workbook_Open()
dim wks as Worksheet

Application.ScreenUpdating = False
For Each wks In ThisWorkbook.Worksheets
wks.Visible = xlSheetVisible
Next wks
ClientDetails.Show
Application.ScreenUpdating = True
End Sub

--
HTH...

Jim Thomlinson


"BOBODD" wrote:

> Im using this code when my workbook opens:
> Private Sub Workbook_Open()
> Dim i As Integer
> For i = 1 To 8
> Sheets(i).Visible = xlVeryHidden
> Next
> Application.ScreenUpdating = False
> For Each Worksheet In ThisWorkbook.Worksheets
> Worksheet.Visible = xlSheetVisible
> Next
> ClientDetails.Show
> End Sub
>
> The first For loop is only there for testing. Eventually this loop will be
> run when the program is closed.
>
> The problem is that although I have the "Application.ScreenUpdating = False"
> there, Excel still shows the sheets being unhidden, along with any updates
> made. I've checked my entire program, and there are ScreenUpdating = True
> statements to change things. What else would cause this?

BOBODD

12/14/2006 1:04:00 AM

0

After rereading this, I wasn't very clear in my original post.

I want all of the sheets hidden. The screenupdating should be switched off,
then all sheets are unhidden, but not shown onscreen. Code will alter some
of these sheets (using info entered thru userforms) and will finally hide all
unaltered sheets, so users only see the worksheets that are relevant to them.

I have removed all the Application.ScreenUpdating = True statements from my
code, so there should be nothing to countermand the "False" statement.
Regardless of this, Excel still shows all of the sheets as they're unhidden
or updating by my code. Is there anything that could cause this?

I tried Jim's suggestion in case it did have something to0 do with it, but
no dice.

"Jim Thomlinson" wrote:

> Worksheet is a reserved word... Give this a try...
>
> Private Sub Workbook_Open()
> dim wks as Worksheet
>
> Application.ScreenUpdating = False
> For Each wks In ThisWorkbook.Worksheets
> wks.Visible = xlSheetVisible
> Next wks
> ClientDetails.Show
> Application.ScreenUpdating = True
> End Sub
>
> --
> HTH...
>
> Jim Thomlinson
>
>
> "BOBODD" wrote:
>
> > Im using this code when my workbook opens:
> > Private Sub Workbook_Open()
> > Dim i As Integer
> > For i = 1 To 8
> > Sheets(i).Visible = xlVeryHidden
> > Next
> > Application.ScreenUpdating = False
> > For Each Worksheet In ThisWorkbook.Worksheets
> > Worksheet.Visible = xlSheetVisible
> > Next
> > ClientDetails.Show
> > End Sub
> >
> > The first For loop is only there for testing. Eventually this loop will be
> > run when the program is closed.
> >
> > The problem is that although I have the "Application.ScreenUpdating = False"
> > there, Excel still shows the sheets being unhidden, along with any updates
> > made. I've checked my entire program, and there are ScreenUpdating = True
> > statements to change things. What else would cause this?

NickHK

12/14/2006 2:46:00 AM

0

You cannot hide ALL the sheets ; there must be one sheet (either a worksheet
or a chart) visible.
Not sure what you mean by "all sheets are unhidden, but not shown onscreen"
.. Sheets are either visible or not.

You can still reference hidden sheets to work with them, but not .Select
anything, which is seldom necessary anyway.

If for some reason, you want the sheet visible, but out of the Excel window,
you can set the Window(1).Top/.Left properties. Although why you would want
to do this, I'm not sure.

NickHK
P.S. It seems ScreenUpdating is always true when stepping through code, so
only expect it work when not in break mode.

"BOBODD" <BOBODD@discussions.microsoft.com> wrote in message
news:ED29D029-5878-47E3-A544-4306CC244134@microsoft.com...
> After rereading this, I wasn't very clear in my original post.
>
> I want all of the sheets hidden. The screenupdating should be switched
off,
> then all sheets are unhidden, but not shown onscreen. Code will alter
some
> of these sheets (using info entered thru userforms) and will finally hide
all
> unaltered sheets, so users only see the worksheets that are relevant to
them.
>
> I have removed all the Application.ScreenUpdating = True statements from
my
> code, so there should be nothing to countermand the "False" statement.
> Regardless of this, Excel still shows all of the sheets as they're
unhidden
> or updating by my code. Is there anything that could cause this?
>
> I tried Jim's suggestion in case it did have something to0 do with it, but
> no dice.
>
> "Jim Thomlinson" wrote:
>
> > Worksheet is a reserved word... Give this a try...
> >
> > Private Sub Workbook_Open()
> > dim wks as Worksheet
> >
> > Application.ScreenUpdating = False
> > For Each wks In ThisWorkbook.Worksheets
> > wks.Visible = xlSheetVisible
> > Next wks
> > ClientDetails.Show
> > Application.ScreenUpdating = True
> > End Sub
> >
> > --
> > HTH...
> >
> > Jim Thomlinson
> >
> >
> > "BOBODD" wrote:
> >
> > > Im using this code when my workbook opens:
> > > Private Sub Workbook_Open()
> > > Dim i As Integer
> > > For i = 1 To 8
> > > Sheets(i).Visible = xlVeryHidden
> > > Next
> > > Application.ScreenUpdating = False
> > > For Each Worksheet In ThisWorkbook.Worksheets
> > > Worksheet.Visible = xlSheetVisible
> > > Next
> > > ClientDetails.Show
> > > End Sub
> > >
> > > The first For loop is only there for testing. Eventually this loop
will be
> > > run when the program is closed.
> > >
> > > The problem is that although I have the "Application.ScreenUpdating =
False"
> > > there, Excel still shows the sheets being unhidden, along with any
updates
> > > made. I've checked my entire program, and there are ScreenUpdating =
True
> > > statements to change things. What else would cause this?