Unhide a Sheet when User Matchs into a list

TEIXEIRE

New Member
Joined
Apr 17, 2020
Messages
33
Office Version
  1. 365
Platform
  1. Windows
Hello,

Sorry, I am introducing in VBA codes,

I have a sheet called "AuthUsers", and in collunm A, I have the windows name (not the user but the name registered) of the responsibles in each row,

I want to open the workbook, and unhiden the sheet called "Week Update", if the Applicatin.UserName matchs in any row of the sheet "AuthUsers"

I did the following code, but didnt work.
Could u help me on that ?

VBA Code:
Sub Authorized_Report_Users()
'Only for hide/unhide specific sheets for users who is responsible to keep report updated

    Var1 = WorksheetFunction.Match(Application.UserName, Sheets("AuthUsers").Columns(1), 0)

    If Not WorksheetFunction.IsError(Var1) Then

        Sheets("Week Update").Visible = True

    End If


End Sub
 
VBA Code:
Option Explicit

Sub ChkUsers()
Dim x As String

On Error Resume Next

Application.ScreenUpdating = False
Sheets("AuthUsers").Visible = True
    With Sheets("AuthUsers")
        x = .Range("A2:A10").Find(Application.UserName) '<-- change the range to suit
      
        If x = Application.UserName Then
            Sheets("Week Update").Visible = True
        Else
            Sheets("AuthUsers").Visible = False
        End If
    End With
Sheets("AuthUsers").Visible = False
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Forum statistics

Threads
1,214,788
Messages
6,121,603
Members
449,038
Latest member
Arbind kumar

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