Macro MsgBox issue

KaaNunL

New Member
Joined
Jun 27, 2019
Messages
9
Hi Everyone,

I have quick question :)

How can i add MsgBox if there is no "fail" current week ?

Is it possible to help me to finish this macro ?

Thank you

Code:
Sub GetFilterForFails()
'
' GetFilterForFails Macro
'


'


Dim CurrentYear As Integer
    Dim previousweek As Integer
    Dim slaUK As String
    


    CurrentYear = DatePart("yyyy", Date)
    previousweek = DatePart("ww", Date) - 1
    slaUK = "SLA builder UK.xlsm"


    Sheets("SLA - Order delivery").Select
    Selection.AutoFilter
    ActiveSheet.ListObjects("tbl_SLA_OrderDelivery").Range.AutoFilter Field:=30, _
        Criteria1:=CurrentYear
    ActiveSheet.ListObjects("tbl_SLA_OrderDelivery").Range.AutoFilter Field:=29, _
        Criteria1:=previousweek
    ActiveSheet.ListObjects("tbl_SLA_OrderDelivery").Range.AutoFilter Field:=28, _
        Criteria1:="Fail"
        
End Sub
 
Last edited by a moderator:

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Does this do the job?

Code:
Sub GetFilterForFails()
'
' GetFilterForFails Macro
'
Dim CurrentYear As Integer
Dim previousweek As Integer
Dim slaUK As String
[COLOR=#ff0000]Dim lFails As Long[/COLOR]

CurrentYear = DatePart("yyyy", Date)
previousweek = DatePart("ww", Date) - 1
slaUK = "SLA builder UK.xlsm"

Sheets("SLA - Order delivery").Select
Selection.AutoFilter
ActiveSheet.ListObjects("tbl_SLA_OrderDelivery").Range.AutoFilter Field:=30, _
Criteria1:=CurrentYear
ActiveSheet.ListObjects("tbl_SLA_OrderDelivery").Range.AutoFilter Field:=29, _
Criteria1:=previousweek
ActiveSheet.ListObjects("tbl_SLA_OrderDelivery").Range.AutoFilter Field:=28, _
Criteria1:="Fail"

[COLOR=#ff0000]On Error Resume Next
lFails = ActiveSheet.ListObjects("tbl_SLA_OrderDelivery").DataBodyRange.SpecialCells(xlCellTypeVisible).Rows.Count
On Error GoTo 0

If lFails = 0 Then MsgBox "ERROR"[/COLOR]

End Sub
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,885
Members
452,364
Latest member
springate

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