hiding sheets using a form

  • Thread starter Thread starter Roger on Excel
  • Start date Start date
R

Roger on Excel

i have a spreadsheet with sheets named as follows

St1, St2, St3, St4, St5 etc...

I would like to enter a number into a cell on a separate sheet that will
only show the sheets up to that number and hide the rest.

For example if i enter 3, I would like St1, St2 and St3 to show and the rest
to be hidden.

I am going to use a form to enter the number into the sheet, but for the
moment i need to find code to do the task first.

Can anyone help?
 
i have a spreadsheet with sheets named as follows

St1, St2, St3, St4, St5 etc...

I would like to enter a number into a cell on a separate sheet that will
only show the sheets up to that number and hide the rest.

For example if i enter 3, I would like St1, St2 and St3 to show and the rest
to be hidden.

I am going to use a form to enter the number into the sheet, but for the
moment i need to find code to do the task first.

Can anyone help?

Try this:

Sub Hide_Show_Sheets
SheetNum = ThisWorkbook.Sheets.Count
LastShow = Worksheets("Sheet1").Range("A1").Value

For c = 1 To SheetNum
If c > LastShow Then
Sheets("St" & c).Visible = False
Else
Sheets("St" & c).Visible = True

End Sub

Regards Per
 
Back
Top