Error Message for SlcerMethod VBA

SophieO

New Member
Joined
Jun 12, 2018
Messages
1
Hi everyone

I'm new to VBA and I'm struggling to add an Error Message which is only shown, if there is no project in the slicer matching the users input. By now, the meassage is always shown, even if a matching project is found.


Code:
        Dim si As SlicerItem, fi As SlicerItem
        'si item in slicer, fi Input des Users
        Dim msg As String
        With ActiveWorkbook.SlicerCaches(1)
        
        On Error GoTo ErrorHandler
        'if there is no matching Project, goto ErrorHandler
        Set fi = .SlicerItems(CStr(Sheets("Neu").Range("A90")))
        'Cell Input from A90 is fi 
        fi.Selected = True
     


        For Each si In .VisibleSlicerItems
        If si.Name <> fi.Name Then si.Selected = False
           
        Next
        
        End With

And here is my ErrorHandler:
Code:
ErrorHandler:
MsgBox "Projekt nicht gefunden", vbOKOnly, "Fehler"


On Error GoTo 0


End Sub

Maybe someone can help me?
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Forum statistics

Threads
1,216,503
Messages
6,131,020
Members
449,615
Latest member
Nic0la

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