hiding sheets using a form

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?
 
P

Per Jessen

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
 

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

Top