The_Gigster
New Member
- Joined
- Nov 4, 2016
- Messages
- 5
Hi
I have a range on a worksheet that I wish to restrict to a number of users based on their application name but, based on the following if the User Name is not in the range, a type mismatch is returned:
Private Sub Workbook_Open()
Dim strUserName As String
strUserName = Application.UserName
Range("AZ1") = strUserName
If strUserName = (Application.VLookup(strUserName, Sheet1.Range("$BA$1:$BA$9"), 1, False)) Then
Columns("G:L").Select
Selection.EntireColumn.Hidden = False
Range("A1").Select
Else
Range("A1").Select
End If
End Sub
Any help will be greatly appreciated. Thanks in advance.
I have a range on a worksheet that I wish to restrict to a number of users based on their application name but, based on the following if the User Name is not in the range, a type mismatch is returned:
Private Sub Workbook_Open()
Dim strUserName As String
strUserName = Application.UserName
Range("AZ1") = strUserName
If strUserName = (Application.VLookup(strUserName, Sheet1.Range("$BA$1:$BA$9"), 1, False)) Then
Columns("G:L").Select
Selection.EntireColumn.Hidden = False
Range("A1").Select
Else
Range("A1").Select
End If
End Sub
Any help will be greatly appreciated. Thanks in advance.