Hiding/Showing a sheet with a variable name based on cell value

Jack3010

New Member
Joined
Jan 26, 2017
Messages
3
Hi,

I have a workbook where the sheets change name depending on cells values in a master sheet but if there are no cell values i want the sheets to hide. Just wondering if anyone could help as im new to VBA

Thanks
Jack
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
You might have a look at Automatically Rename Worksheet Based On Cell Value From Another Sheet

Here is a snippet I made that you can put in your master sheet module. If you put the word Change in A1 and C5, and then click on them, you should see Sheet1's name change


Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$A$1" And UCase(Target) = "CHANGE" Then
    Sheet1.Name = "Josephine"
End If
If Target.Address = "$C$5" And UCase(Target) = "CHANGE" Then
    Sheet1.Name = "Sheet1"
End If
End Sub
 
Upvote 0
This is how you would hide a sheet based on A1 being empty

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("A1").Value = "" Then
    Sheet1.Visible = False
    Else
    Sheet1.Visible = True
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,221,418
Messages
6,159,791
Members
451,589
Latest member
Harold14

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top