Sub rrrrr(myD As Variant, Optional myD1 As Variant, Optional myD2 As Variant, Optional myD3 As Variant) ' ' Макрос3 Макрос ' If IsMissing(myD1) = True Then myD1 = myD End If If IsMissing(myD2) = True Then myD2 = myD End If If IsMissing(myD3) = True Then myD3 = myD End If ' On Error GoTo ErrorHandler 'myD = "ООО ромашка 1" 'myD1 = "ООО ромашка 2" 'myD2 = "ООО ромашка 9" 'myD3 = "ООО ромашка 10" With ActiveSheet.PivotTables("СводнаяТаблица1").PivotFields("Компания") For Each PItem In .PivotItems PItem.Visible = True Next For Each PItem In .PivotItems PItem.Visible = True If PItem.Name = myD _ Or PItem.Name = myD1 _ Or PItem.Name = myD2 _ Or PItem.Name = myD3 Then PItem.Visible = True Else: PItem.Visible = False End If Next End With Exit Sub ErrorHandler: With ActiveSheet.PivotTables("СводнаяТаблица1").PivotFields("Компания") For Each PItem In .PivotItems PItem.Visible = True Next End With End Sub Sub Макрос4() Call rrrrr("ООО ромашка 10", "ООО ромашка 1", "ООО ромашка 12", "ООО ромашка 1255") End Sub