VBA to Hide Tabs based on Cell contents located in a "Log" tab

Evremonde

New Member
Joined
Sep 29, 2016
Messages
25
Hello All:

I have a workbook that has a tab named "Log". The workbook also has many other tabs as well. In the "Log" worksheet, range A3:A200 contains tabs names. Range D3:D200 contains either "Yes" or "No" or "...". I would like to add VBA to hide tabs where (for example) if D3 contains "No", the tab name found in A3 hides. This VBA working for the ranges described. I would like to assign to a 'button' to run the VBA as necessary.

Thank you for the assistance...

~l
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
How about
Code:
Sub Evremonde()
   Dim Cl As Range
   
   With Sheets("Log")
      For Each Cl In .Range("A3", .Range("A" & Rows.Count).End(xlUp))
         If Cl.Value <> "" Then
            If Evaluate("isref('" & Cl.Value & "'!A1)") Then
               Sheets(Cl.Value).Visible = Cl.Offset(, 3).Value = "Yes"
            End If
         End If
      Next Cl
   End With
End Sub
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0
Hello Fluff:

Referring to the VBA in this thread. I have a spreadsheet with tab names "Log", "A","B", and "C". These are referenced in the "Log" tab beginning st A3. The VBA works fine. However, if I add a tab named "1000" and reference "1000" in the "Log" tab as described, I get a 'subscript out of range' error and debug points to "Sheets(Cl.Value).Visible = Cl.Offset(, 3).Value = "Yes". Can you diagnose?

~e
 
Upvote 0
If you have numbers, they need to be converted to strings, like
Code:
               Sheets(CStr(Cl.Value)).Visible = Cl.Offset(, 3).Value = "Yes"
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,892
Messages
6,175,236
Members
452,621
Latest member
Laura_PinksBTHFT

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