Hello all
I have a series of models that I've added an Index tab to, and I've written code that lists all of the tab names in one column, and in the next column then lists the current visibility status of each tab. Next to this is a third column that then allows me to manually select whether the tab should be visible or hidden (I need to lock down the access of the models to limited tabs for other users).
I've tried writing a macro that looks through each sheet name listed, and then offsets to the column where I've selected Visible or Hidden, and if the value is Hidden it hides the sheet for me. I just wanted a quick solution rather than having to manually hide/unhide sheets every time. My code is below:
However when I run the code it stops at the![]()
Sub HideRequiredSheets() Dim wb As ThisWorkbook Dim ws As Worksheet Dim ShtName As Range Dim ShtNames As Range Set ShtNames = Range("C8:C29") For Each ShtName In ShtNames If ShtName.Offset(0, 4).Value = "Hidden" Then ws(ShtName).Visible = xlHidden End If Next ShtName End Subline and gives me the 'Object Variable or With Block Variable not set' error message.![]()
ws(ShtName).visible = xlHidden
Can anyone help please?
Thanks all
Bonnister











LinkBack URL
About LinkBacks


Register To Reply

Bookmarks