PDA

View Full Version : [SOLVED:] Unhide Worksheet on Selection of Cell



dj44
12-29-2016, 11:10 AM
Hi folks,:)

Good Thursday,

I am trying to unhide worksheets listed in column B

The below should work but I can't spot the typo or error.

The name of the Worksheet is listed in Column B, when the cell is clicked it should unhide the worksheet
Example Click B2 that has the name of the worksheet 1, click B3 Unhide TestWS

B2 ---- > Worksheet 1

B3 ----- > TestWS

B4 ------ > Data

etc



Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Dim oWs As Worksheet
On Error Resume Next
If Not Intersect(ActiveCell, Range("B2:B6")) Is Nothing Then
oWs.Name = ActiveCell.Text
oWs.Visible = xlSheetVisible
End If
End Sub



thank you

NoSparks
12-29-2016, 11:47 AM
oWs is not a worksheet. It is the text string in the cell that is to be used to specify the name of the worksheet.


Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Dim oWs As String

On Error Resume Next
If Not Intersect(ActiveCell, Range("B2:B6")) Is Nothing Then
oWs = ActiveCell.Text
Sheets(oWs).Visible = xlSheetVisible
End If

End Sub

dj44
12-29-2016, 11:58 AM
Thanks NoSparks,

worked perfectly, I thought i had this one - but could not find the right syntax

Have a great day!

:)