Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Sridhar Rao
 
Posts: n/a
Default Check boxes to show/hide Tabs

Checkboxes to show/hide tabs...
  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default

Sridhar,

Here is a way which adds a couple of options to the sheet tab right-click
(Ply) menu.

First build a form with a listbox and 4 commandbuttons, with name & captions
of

lstSheete & null
cmdOK & OK
cmdCancel & Cancel
cmdSelectAll & Select All
cmdDeselectAll & Deselect All

Add this code to tyhe form

Option Explicit

Private Sub UserForm_Initialize()
Dim i As Long
lstSheets.Clear
With ActiveWorkbook
For i = 1 To .Sheets.Count
If .Sheets(i).Visible = False Then
lstSheets.AddItem (.Sheets(i).Name)
End If
Next
End With
End Sub

Private Sub cmdCancel_Click()
Unload frmUnhideSheets
End Sub

Private Sub cmdOK_Click()
Dim i As Long
Unload frmUnhideSheets
Application.ScreenUpdating = False
For i = 0 To lstSheets.ListCount - 1
'If an item is selected, unhide that sheet.
If lstSheets.Selected(i) = True Then
With ActiveWorkbook.Sheets(lstSheets.List(i))
.Visible = True
.Activate
End With
End If
Next
End Sub

Private Sub cmdSelectAll_Click()
Dim i As Long
For i = 0 To lstSheets.ListCount - 1
lstSheets.Selected(i) = True
Next
End Sub

Private Sub cmdDeselectAll_Click()
Dim i As Long
For i = 0 To lstSheets.ListCount - 1
lstSheets.Selected(i) = False
Next
End Sub


Then put this code in the ThisWorkbbok module to build the menu

Private Sub Workbook_BeforeClose(Cancel As Boolean)

MenuRemovePly

End Sub

Private Sub Workbook_Open()

MenuRemovePly
MenuAddPly

End Sub


And finally, put this code in a standard bas module

Private Sub HideSheet()
ActiveWindow.SelectedSheets.Visible = False
End Sub

Private Sub UnhideSheet()
frmUnhideSheets.Show
End Sub

Public Sub MenuAddPly()
With Application.CommandBars("Ply")
.Controls.Add(Type:=msoControlButton).Caption = _
"Hide Sheet(s)"
.Controls.Add(Type:=msoControlButton).Caption = _
"Unhide Sheet(s)..."
.Controls("Hide Sheet(s)").BeginGroup = True
.Controls("Hide Sheet(s)").OnAction = "HideSheet"
.Controls("Unhide Sheet(s)...").OnAction = "UnhideSheet"
End With
End Sub

Public Sub MenuRemovePly()
With Application.CommandBars("Ply")
.Controls("Hide Sheet(s)").Delete
.Controls("Unhide Sheet(s)...").Delete
End With
End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Sridhar Rao" wrote in message
...
Checkboxes to show/hide tabs...



Reply
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
How do I use a check box to accept a calculation Joejoethecrackman Excel Discussion (Misc queries) 5 March 22nd 05 08:47 PM
Creating Formula using check boxes Anthony Slater Excel Discussion (Misc queries) 3 January 4th 05 03:03 PM
Creating a check box that does not require security clearance. Maverick2U Excel Worksheet Functions 6 December 14th 04 02:46 AM
Sheet tabs disappear sometimes in Internet Explorer Jan Nordgreen Excel Discussion (Misc queries) 0 December 6th 04 01:34 AM
how to incert multiple check boxes in excel AnneW Excel Worksheet Functions 1 November 19th 04 06:50 PM


All times are GMT +1. The time now is 04:51 AM.

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

About Us

"It's about Microsoft Excel"