I have a project were a user needs to enter an Excel "temporary" view when they open an excel document. My code works for the individual user, but I wanted to know if there was a way to determine if the user was part of a permissions group.
The goal is that if the person is not in the group, they go to the default layout. If they are in the permissions group, they get sent to a specific view.
This test code is working with regards to setting up and activating the temp view. I just want to see if I can add this one feature.
Example:
Group 1 (sent to temp view)
- Bob
- Fred
- Sam P.
Not in Group (not sent to temp view, but user view created)
- Mike
- Andy
- Sam Y.
Code Steps:
1) Check to see if user is in Permissions Group 1
2) If user not in Permissions Group 1
Thanks,
Mike
The goal is that if the person is not in the group, they go to the default layout. If they are in the permissions group, they get sent to a specific view.
This test code is working with regards to setting up and activating the temp view. I just want to see if I can add this one feature.
Example:
Group 1 (sent to temp view)
- Bob
- Fred
- Sam P.
Not in Group (not sent to temp view, but user view created)
- Mike
- Andy
- Sam Y.
Code Steps:
1) Check to see if user is in Permissions Group 1
IF Yes: Check if user has a temp view created
If YES: Go to temp view
If NO: Create temp view and activate it
2) If user not in Permissions Group 1
IF Yes: Go to default view and check to see if user has temp view
IF NO: create temp view, but stay in default view
Code:
Sub test()
On Error GoTo create_view
user_name = VBA.Interaction.Environ$("UserName")
ActiveSheet.NamedSheetViews.GetItem(user_name).Activate
GoTo end_view
create_view:
ActiveSheet.NamedSheetViews.EnterTemporary
ActiveSheet.NamedSheetViews.GetItem("").Name = user_name
ActiveSheet.NamedSheetViews.GetItem(user_name).Activate
end_view:
End Sub
Thanks,
Mike