hiding worksheets programmatically

  • Thread starter Thread starter JohnE
  • Start date Start date
J

JohnE

I have an inherited workbook that when it is all done running the scenarios,
etc, there are a extra sheets. These have the standard "Sheet" + number on
the tab while those reviewed and needed are actually named. I would like to
hide these unused sheets at the end of the running process. But I am at a
loss of how that would be accomplished, so I seek help from the group.
Thanks.
.... John
 
That I know. I need to use code to hide them. The number of the sheets will
vary from run to run.
.... John
 
you can try these

worksheets("Sheet1").visible = false
worksheets("Sheet1").visible = true
worksheets("Sheet1").visible = xlveryhidden
 
Will the sheets you are not hiding always have similar
characteristics? Do these sheets have anything you need? You might
delete them too.

Perhaps you could adapt this

Sub HideSheets()
For Each ws In Worksheets
If Left(ws.Name, 5) = "Sheet" Then ws.Visible = False
Next ws
End Sub

Scott
 
You said these were extra sheets. I assumed they were unnecessary and you
just wanted them out of the way. If they were created by the macro during
the execution and are used somewhere along the line, then you will need to
think about how you are going to handle this situation. Will the macro
create new sheets each time or will you just unhide the sheets. Since you
did not specify how the extra sheets came into existence and what, if any,
significance they have in the execution of the macro, maybe Gary's posting
offers the best information.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top