Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Hiding Worksheets

  Asked By: Josefina    Date: Jan 30    Category: MS Office    Views: 844
  

I want to hide a few worksheets in the workbook I am creating. I
would like to hide these worksheets, call them sheet 1 and sheet 2,
upon opening the workbook. I would also like to have another macro
that will allow me to unhide them, which I would put in a command
button. I am having some trouble with this. Please help if
possible.

Share: 

 

4 Answers Found

 
Answer #1    Answered By: Mansur Bashara     Answered On: Jan 30

I dont know whats the trouble  in this, as long as I can see the
code. You said you want to hide  the worksheet.

You can specify it as

Worksheets("Sheet1").Select
Selection.Hide

or

Worksheets("Sheet1).Visible = False
Worksheets("Sheet2").Visible = False.

Either of the statements can be used. But i dont know, when exactly
you want to hide the sheets. For eg: either when you open the
workbook, you can hide the sheets which you told or before you close
the application, you can hide the sheets.

When you talked about unhiding the sheets. specify in the button
event handler, the sheet  name. For eg:

Private Sub CommandButton1_click()
Worksheets("Sheet1").Visible = True
Worksheets("Sheet2").Visible = True
End Sub

 
Answer #2    Answered By: Farah Khan     Answered On: Jan 30

I got how to hide  the sheets, but want to
know how to hide them when I open the workbook. Thank you for the
help! Sorry, not very experienced with VBA.

 
Answer #3    Answered By: Eline Bakker     Answered On: Jan 30

When you open the Visual Basic editor, you could find something called
ThisWorkBook. In this, you have to write the following code:

Private Sub Workbook_open()
Application.ScreenUpdating = False

Worksheets("Sheet1").Visible = False
Worksheets("Sheet2").Visible = False.

Application.ScreenUpdating = True
End Sub

So, when you open the workbook, the workbook_open event gets
triggered, which automatically executes the lines in that event
procedure. So, thereby you could make ur sheets invisible.

ScreenUpdating is set to false, becoz you dont want any screen
flickering when the processor is processing the task. You may not
find big difference for this process, but when you want to process a
large value and enter each value into the cells, then if you dont
provide that statement, you cud see the screen getting flickered,
which is not a good thing to see. also, lot of memory is wasted for
it, which indirectly slows down the process (ie) processing time is
larger.

 
Answer #4    Answered By: Harriet Hughes     Answered On: Jan 30

Open Visual Basic Editor, then click on "ThisWorkbook" in Project-
VBAProject and paste this code

Private Sub Workbook_Open()
Sheets("Sheet1").Visible = False
Sheets("Sheet2").Visible = False
End Sub

This code will hide  Sheet1 and Sheet2 upon opening  the workbook

 
Didn't find what you were looking for? Find more on Hiding Worksheets Or get search suggestion and latest updates.




Tagged: