Worksheet Change code

ManUBlueJay

Active Member
Joined
Aug 30, 2012
Messages
320
Office Version
  1. 365
Platform
  1. Windows
I have 2 slicers running a pivot table on a sheet called "Entry Form"
Slicer 1 is controlling a named cell called "CEF_Entry"
Slicer 2 is controlling a named range called "CEF_Type"

I would like it that when I change slicer 1 it clears Slicer 2' selection and locks my entry form requiring a selection from Slicer 2. My code does never reach the slicer 2 change
When Slicer 2 is used it unlocks my entry form.
I have used the following code in the relevant sheet code

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("CEF_Entry")) Is Nothing And Range("CEF_Type") = "(All)" Then
Exit Sub
Else
If Not Intersect(Target, Range("CEF_Type")) Is Nothing Then
Application.EnableEvents = False
CompostEntryForm
Application.EnableEvents = True
Else
If Not Intersect(Target, Range("CEF_Entry")) Is Nothing And Range("CEF_Type") <> "(All)" Then
Application.EnableEvents = False
Sheets("Entry Form").Unprotect
ActiveWorkbook.SlicerCaches("Slicer_Type").ClearManualFilter
Range("CompostEntryForm").Locked = True
Sheets("Entry Form").Protect AllowUsingPivotTables:=True, UserInterFaceOnly:=True
Application.EnableEvents = True
End If
End If
End If
End Sub
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Forum statistics

Threads
1,223,896
Messages
6,175,260
Members
452,627
Latest member
KitkatToby

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