Hey guys,
I've got a database of workshops and created a userform for login purpose.
Once the workshop successfully login to the workbook, they can see 2 worksheets with data necessary for them to track their KPI results.
There are multiple slicers on both worksheets, but one is crucial and it's called "workshops". There is also one hidden worksheet called "admin" with columns in respective order:
workshoplogin / workshopassword / workshops
So:
After the workshopAAA sucessfully logins to the workbook all the data in the workbook is automatically filtered to the data related to this workshopAAA and it's perfect.
Problem is:
I don't know how to disable "workshop slicers" from being "clicked". I dont want workshopAAA to see data of the workshopBBB.
WorkshopAAA can't see other Workshops data/results/charts. But other slicers must be unlocked so WorkshopAAA can see how they perform in different product categories.
I tried with worksheet protection but after the workshopAAA logins to the workshop I get an error that pivottable can't be modified when worksheet is protected.
Much thanks for help!
I've got a database of workshops and created a userform for login purpose.
Once the workshop successfully login to the workbook, they can see 2 worksheets with data necessary for them to track their KPI results.
There are multiple slicers on both worksheets, but one is crucial and it's called "workshops". There is also one hidden worksheet called "admin" with columns in respective order:
workshoplogin / workshopassword / workshops
workshoplogin | workshopassword | workshops in slicers |
Dim as serwis_log | Dim as serwis_pass | Dim as serwis_slicer |
So:
After the workshopAAA sucessfully logins to the workbook all the data in the workbook is automatically filtered to the data related to this workshopAAA and it's perfect.
Problem is:
I don't know how to disable "workshop slicers" from being "clicked". I dont want workshopAAA to see data of the workshopBBB.
WorkshopAAA can't see other Workshops data/results/charts. But other slicers must be unlocked so WorkshopAAA can see how they perform in different product categories.
I tried with worksheet protection but after the workshopAAA logins to the workshop I get an error that pivottable can't be modified when worksheet is protected.
Much thanks for help!
VBA Code:
Private Sub login_BT_Click()
If serwisy_CB.Value = "" Then
MsgBox "Należy wybrać serwis", vbInformation, "Serwis"
Exit Sub
End If
If password_TB.Value = "" Then
MsgBox "Należy podać hasło", vbInformation, "Hasło"
Exit Sub
End If
If serwisy_CB.Value = "Admin" And password_TB.Value = "admin" Then
Unload Me
Dim Ws As Worksheet
For Each Ws In ActiveWorkbook.Worksheets
Ws.Visible = xlSheetVisible
Next Ws
Sheets("Admin").Select
Else
Dim serwis_log As String
Dim serwis_pass As Variant
Dim serwis_slicer As Variant
serwis_log = serwisy_CB.Value
serwis_pass = Application.WorksheetFunction.VLookup(serwis_log, Sheets("Admin").Range("A:C"), 2, 0)
serwis_slicer = Application.WorksheetFunction.VLookup(serwis_log, Sheets("Admin").Range("A:C"), 3, 0)
If serwis_pass <> password_TB.Value Then
MsgBox "Hasło nie pasuje!", vbInformation, "Błędne hasło"
Exit Sub
End If
If serwis_pass = password_TB.Value Then
Unload Me
Sheets("Dashboard").Visible = True
Sheets("Dashboard2").Visible = True
Sheets("Dashboard").Select
Sheets("Dashboard").Activate
With ActiveWorkbook.SlicerCaches("Slicer_Workshop")
.ClearManualFilter
For Each oSlicerItem In .SlicerItems
If oSlicerItem.Name = serwis_slicer Then
oSlicerItem.Selected = True
Else
oSlicerItem.Selected = False
End If
Next oSlicerItem
End With
With ActiveWorkbook.SlicerCaches("Slicer_Workshop11")
.ClearManualFilter
For Each oSlicerItem In .SlicerItems
If oSlicerItem.Name = serwis_slicer Then
oSlicerItem.Selected = True
Else
oSlicerItem.Selected = False
End If
Next oSlicerItem
End With
End If
End If
End Sub