I have VBA code in Excel which restrict access to a workbook depending on the user login detail, the workbook contains 11 sheets, worksheet are asigned to different user depending on the user login detail The problem I have is when i open other worksheet or workbook the VBA code starts to effect the other worksheet/ workbook, is there a way I can stop this from happening.
please help
Can you post your code - without knowing what you are doing it is hard to answer. Just post the code you feel is affecting the other workbooks i.e how you are restricting access to sheets in the main workbook based on user login details.
Hope this helps.
Anthony
Pack my box with five dozen liquor jugs
PS: Remember to mark your questions as Solved once you are satisfied. Please rate the answer(s) by selecting the Star in the lower left next to the Triangle. It is appreciated”
please find code attached
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
For Each sh In ActiveWorkbook.Sheets
If sh.Name = "cover" Then
Sheets("Summary").Visible = True 'Must have at least one sheet open
GoTo nEXTsH
End If
Sheets(sh.Name).Visible = False 'Hide all other sheets on Close
nEXTsH:
Next sh
End Sub
Private Sub Workbook_Open()
USN = Environ("USERNAME")
'Expose all sheets for Administrator only.
If USN = "dave" Then
For Each sh In ActiveWorkbook.Sheets
sh.Visible = True 'Expose sheet for Administrator only
Next sh
Exit Sub
'Unhide Summary + users own sheet only
Else
For Each sh In ActiveWorkbook.Sheets
If sh.Name = "Summary" Then
Sheets("Summary").Visible = True
ElseIf sh.Name = USN Then
Sheets(USN).Visible = True
Else: Sheets(sh.Name).Visible = False 'hides all other sheets
End If
Next sh
End If
End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks