Macro that unhides sheet tabs

S

Sunnyskies

Hi from Sunny RSA,

Looking for a macro that once a cell is selected (D5) then a tab called the
same as cell D5 unhides itself.

Thanks
 
D

Don Guillett

Right click sheet tab>view code>copy/paste this. If sheet2 is hidden and
sheet2 is typed into the cell and you then select that cell sheet2 will be
visible

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next
Sheets(CStr(Target)).Visible = True
End Sub
 
O

Otto Moehrbach

Surely you don't want this to work on just one cell (D5). I'll assume you
want this to work on D5:F10. The following macro will do what you want
whenever any cell in the range D5:F10 is selected. Note that this macro
must be placed in the sheet module of the sheet that holds the D5:F10 sheet
names. To access that module, right-click on the sheet tab, select View
Code, and paste this macro into that module. "X" out of the module to
return to your sheet. HTH Otto
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("D5:F10")) Is Nothing Then
Sheets(Target.Value).Visible = True
End If
End Sub
 
M

Mike H

Maybe this

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Target.Address = "$D$5" Then
On Error Resume Next
Application.EnableEvents = False
Sheets(Target.Text).Visible = True
Application.EnableEvents = True
On Error GoTo 0
End If
End Sub

Mike
 
D

Dave

Hi,
Try this, entered onto the VBA sheet window - the same sheet as the D5
thingy is on.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next
If Target.Address = Range("D5").Address Then
Sheets(Range("D5").Value).Visible = True
End If
End Sub

Regards - Dave.
 

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