Reducing & increasing tabs on display

C

Colin Hayes

Hi

I have a worksheet with many tabs along the bottom.

To keep the display neat and accessible , and for security reason , I'd
like to sometimes hide / unhide the tabs one-by-one.

I'd like to put 2 buttons one my first page.

One button with each click would hide the last tab in the row one-by-one
, the other button would unhide them one-by-one.

Is this possible?


Grateful for any help

Drno
 
G

Guest

Here are the 2 macros, now attach them to buttons.
HTH,
Gary Brown

'/=================================================/
Public Sub HideEm()
Dim i As Long
Dim iWkshtCount As Long

On Error GoTo err_Sub

iWkshtCount = Application.Worksheets.Count

If iWkshtCount > 1 Then
For i = iWkshtCount To 1 Step -1
If Worksheets(i).Visible = xlSheetVisible Then
Worksheets(i).Visible = xlSheetHidden
Exit For
End If
Next i
End If

exit_Sub:
Exit Sub

err_Sub:
GoTo exit_Sub

End Sub
'/=================================================/

Public Sub UnhideEm()
Dim i As Long
Dim iWkshtCount As Long

On Error GoTo err_Sub

iWkshtCount = Application.Worksheets.Count

If iWkshtCount > 1 Then
For i = 1 To iWkshtCount
'do not process very hidden worksheets
If Worksheets(i).Visible = xlSheetHidden Then
Worksheets(i).Visible = xlSheetVisible
Exit For
End If
Next i
End If

exit_Sub:
Exit Sub

err_Sub:
GoTo exit_Sub

End Sub
'/=================================================/
 
C

Colin Hayes

=?Utf-8?B?R2FyeSBCcm93bg==?= said:
Here are the 2 macros, now attach them to buttons.
HTH,
Gary Brown

HI Gary

OK that works a treat. Very neat.

Thanks!


Best Wishes

Drno
 

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