LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default Hiding/Exposing Worksheets based on a Number Entry

Create a worksheet named Index and move it to the leftmost position.

Then drop a command button from the Forms toolbar onto that Index worksheet.

Assign it this macro:

Option Explicit
Sub auto_open()

Dim wCtr As Long
Dim HowMany As Long

Application.ScreenUpdating = False

Worksheets("index").Visible = xlSheetVisible

For wCtr = 1 To Worksheets.Count
If Worksheets(wCtr).Name = Worksheets("index").Name Then
'skip it
Else
Worksheets(wCtr).Visible = xlSheetHidden
End If
Next wCtr

HowMany = CLng(Application.InputBox(Prompt:="how many to show?", Type:=1))

If HowMany < 1 Then
'do nothing
Else
If HowMany Worksheets.Count - 1 Then
HowMany = Worksheets.Count - 1
End If

For wCtr = 2 To HowMany + 1
Worksheets(wCtr).Visible = xlSheetVisible
Next wCtr
End If

Application.ScreenUpdating = True

End Sub

By naming it auto_open, it actually runs when the workbook opens. And hides all
the other worksheets.

But it still can be run via the button.


David wrote:

I have a worksheet that has data for up to 50 technicians. Each location gets
this workbook and may have from 3-50 technicians. I'd like to create a
macro/formula that lets each location enter the number of technicians, and
then will hide the unneeded worksheets.
The workbook has a summary page, (worksheet one), fifty individual
technician pages (worksheets 2-51) and a setup page (worksheet 52). Data is
entered on each technicians page.
What I would like is for the location to entry a number in a cell or from a
macro prompt that asks how many locations they have. Based on that response,
say 10, would leave the first 10 technician pages, but hide the other 40.
Any suggestions? Thanks!


--

Dave Peterson
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Row filtering based on input box entry (column heading) Santed593 Excel Worksheet Functions 4 August 18th 05 12:35 AM
Insert a number of rows based on a value in a cell on active row iRocco Excel Discussion (Misc queries) 1 August 11th 05 06:18 AM
Is there away to have specific cells unlock based on the entry of information in another? Marc New Users to Excel 2 April 17th 05 06:09 PM
Subtracting based on number of miles Ms Chewie Excel Discussion (Misc queries) 3 December 21st 04 05:35 AM
Increase Number of Worksheets Hoochi Coochi Man Excel Discussion (Misc queries) 4 December 10th 04 04:17 PM


All times are GMT +1. The time now is 11:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"