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

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,021
Latest member
Mohamed Magdi Tawfiq Emam

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