How could I adjust the below code to popup a message box if there is now data on sheet filtered
Code:
Sub DistributeRows()
Application.ScreenUpdating = False
Dim wsAll As Worksheet
Dim wsCrit As Worksheet
Dim wsNew As Worksheet
Dim Lastrow As Long
Dim LastRowCrit As Long
Dim i As Long
Set wsAll = Worksheets("Filtered") ' change All to the name of the worksheet the existing data is on
Lastrow = wsAll.Range("A" & Rows.Count).End(xlUp).Row
Set wsCrit = Worksheets.Add
' column AA has the criteria eg project ref
wsAll.Range("AA1:AA" & Lastrow).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=wsCrit.Range("A1"), Unique:=True
LastRowCrit = wsCrit.Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To LastRowCrit
Set wsNew = Worksheets.Add
wsNew.Name = "Week" & wsCrit.Range("A2")
wsAll.Rows("1:" & Lastrow).AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=wsCrit.Range("A1:A2"), _
CopyToRange:=wsNew.Range("A1"), Unique:=False
wsCrit.Rows(2).Delete
Next i
Application.DisplayAlerts = False
wsCrit.Delete
Application.DisplayAlerts = True
End Sub