Need help writing a VBA code excel

LearningOnMyOwn

New Member
Joined
Jan 4, 2017
Messages
4
I am a beginner and need things outlined very detailed.

I am creating a file for scheduling. In the User tab, in column A I have Admin User Names. I have a code written that in C4 "Username" cell it displays the username of the person. This is from the network. I want to write a code that will make the Users tab Very Hidden if their user name does not appear in the list in column A.

If A2:A1000 = C4 (Username) then Users tab is visible
If not then Users tab is Very Hidden

I will probably need help knowing which sheets to insert the codes.
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Hi L O M O, welcome to the board.

Try this in the sheet module of the sheet with the usernames. (The same sheet with the C4 username display)

This relies on a sheet_change_event which I believe C4 will produce when the username is entered.

Change the sheet names to match exactly your sheet tab name. I am using Sheet2.

Howard

Code:
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)

If Intersect(Target, Range("$C$4")) Is Nothing Or Target.Cells.Count > 1 Then Exit Sub

Dim uNme As String
uNme = Cells(4, 3)

If WorksheetFunction.CountIf(Sheets("Sheet2").Range("A:A"), uNme) = 0 Then

  Sheets("Sheet2").Visible = xlVeryHidden

End If

End Sub

To UN-Hide sheet2, use this. Copy to the ThisWorkbook sheet module and run it with a button or from Alt + f8 key action.

Code:
Sub v_UN_Hide()
'
Sheets("Sheet2").Visible = True
'
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,685
Members
449,117
Latest member
Aaagu

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