VBA ARRAY Logic

RLGY_LONG

New Member
Joined
Apr 15, 2019
Messages
4
For context I am trying to hide tabs based upon the specified user of my model and I want to make it dynamic such that if new tabs were to come into the model....all I would have to do is say if it were true or false based upon the specified user. I have 5 different users lets call them (WL_business user, YL_business user, WL model developer, YL model developer, Model Developer)

I already have a vba that generates all the tabs in the current worksheet (Below) but I do not know how to link the array (Below) from which I specify the user and whether the tab is suppose to be hidden based upon the true false argument.

Can anyone help with this? I would assume you have to specify the array your pulling from (mind you that will not be static) and the based upon the row the formula has to specify whether the user should have the tab hidden or not. :confused:

Array I am using
[TABLE="width: 593"]
<colgroup><col><col><col span="5"></colgroup><tbody>[TR]
[TD]INDEX[/TD]
[TD]SHEET NAME [/TD]
[TD] WLBU[/TD]
[TD] YLBU[/TD]
[TD] YLMD[/TD]
[TD] WLMD[/TD]
[TD] MD[/TD]
[/TR]
[TR]
[TD="align: right"]1[/TD]
[TD]User Specification[/TD]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]TRUE[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD]Button_Check [/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]TRUE[/TD]
[/TR]
[TR]
[TD="align: right"]3[/TD]
[TD]Error Check[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]TRUE[/TD]
[/TR]
[TR]
[TD="align: right"]4[/TD]
[TD]Admin[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]TRUE[/TD]
[/TR]
[TR]
[TD="align: right"]5[/TD]
[TD]Dashboard WL[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]TRUE[/TD]
[/TR]
[TR]
[TD="align: right"]6[/TD]
[TD]Dashboard YL[/TD]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]TRUE[/TD]
[/TR]
[TR]
[TD="align: right"]7[/TD]
[TD]Dashboard YLL[/TD]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]FALSE[/TD]
[TD="align: center"]TRUE[/TD]
[TD="align: center"]TRUE[/TD]
[/TR]
</tbody>[/TABLE]

Sub I have
Sub ListSheetNamesInNewWorkbook()


Dim objNewWorksheet As Worksheet


Set objCurrentWorksheet = ThisWorkbook.ActiveSheet

For i = 1 To ThisWorkbook.Sheets.Count
objCurrentWorksheet.Cells(i + 1, 1) = i
objCurrentWorksheet.Cells(i + 1, 2) = ThisWorkbook.Sheets(i).Name
Next i
With objCurrentWorksheet
.Columns("A:B").AutoFit
End With
End Sub

Thanks
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Hi & welcome to MrExcel.
How do you determine which group a user is in?
Also what sheet is the list on?
 
Upvote 0
Hi Fluff,

Thanks for the quick response. I determine the group by buttons on the user specification tab.

The sheet the list is on is Button_Check AH.

LMK if you have any other questions.
 
Upvote 0
So will you have one button for each group? & want the code to run when the button is clicked?
 
Upvote 0
For the WLBU group use
Code:
   Dim Cl As Range
   
   With Sheets("Button_Check AH")
      For Each Cl In .Range("B2", .Range("B" & Rows.Count).End(xlUp))
         Sheets(Cl.Value).Visible = Cl.Offset(, [COLOR=#ff0000]1[/COLOR]).Value
      Next Cl
   End With
And change the red 1 to 2 for the next group, then 3 etc
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,254
Members
452,623
Latest member
Techenthusiast

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