ciao, temo di no anche perchè è collegato a tabelle su server...
ora credo di essere vicino ad una soluzione, ho fatto in modo da poter gestire 2 eventi sotto a Worksheet_Change.
l'unica cosa che sto riscontrando è che appena aperto il file il codice funziona ma se ho un errore di codice poi non esegue più nulla! ok che non devono esserci bug ma la cosa è strana, stavo cercando un modo per "Riattivare" l'evento Worksheet_Change
detto ciò, qui sotto il codice a cui sono arrivato adesso:
rivate Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo myerror
Application.EnableEvents = False
Dim ccr As Range, acr As Range
Set ccr = Range("A4") '<<< prima cella su cui lavorare dopo aggiornamento del dato
For Each Cell In ccr
Dim xPTable As PivotTable
Dim xPFile As PivotField
Dim xStr As String
If Not Application.Intersect(Target, Range("A4")) Is Nothing Then
Application.ScreenUpdating = False
Range("C4") = ""
Range("I4") = ""
Set xPTable = Worksheets(ActiveSheet.Name).PivotTables("Tabella pivot1")
Set xPFile = xPTable.PivotFields("FAMILY_CODE")
xStr = Target.Text
xPFile.ClearAllFilters
xPFile.CurrentPage = xStr
Application.ScreenUpdating = True
If IsEmpty(ActiveSheet.Range("A4")) Then ActiveSheet.Range("C4", "F4", "I4").Value = ""
End If
Next Cell
Set acr = Range("C4") '<<< seconda cella su cui lavorare dopo aggiornamento del dato
For Each Cell In acr
Dim xPTable2 As PivotTable
Dim xPFile2 As PivotField
Dim xStr2 As String
If Not Application.Intersect(Target, Range("C4")) Is Nothing Then
Application.ScreenUpdating = False
'Range("C4") = ""
Range("I4") = ""
Set xPTable2 = Worksheets(ActiveSheet.Name).PivotTables("Tabella pivot2")
Set xPFile2 = xPTable2.PivotFields("PROD_TYPE")
Range("F4").FormulaR1C1 = "=IFERROR(MID(RC[-3],SEARCH(""M"",RC[-3])+1,SEARCH(""E"",RC[-3],SEARCH(""M"",RC[-3])+1)-SEARCH(""M"",RC[-3])-1),"""")"
xStr2 = Target.Text
xPFile2.ClearAllFilters
xPFile2.CurrentPage = xStr2
Application.ScreenUpdating = True
If IsEmpty(ActiveSheet.Range("A4")) Then ActiveSheet.Range("F4", "I4").Value = ""
End If
Next Cell
Application.EnableEvents = True
myerror:
Application.EnableEvents = True
Application.ScreenUpdating = True
Exit Sub
End Sub