I'm having an issue with my macro. It will filter on X criteria in a column, copy all that data, then paste into new sheet and save. If X criteria does not exist in the column, it will still go on to save as a new sheet and the sheet will be blank and have a huge file size. How can I get VBA to check if X criteria exists in Y column, and if so, continue the macro. Otherwise, skip the entire private sub.
This is the section I'm having issues with. I'm thinking maybe using an If-Else statement might work but I'm not sure how to incorporate that properly....like If Column 21 has "X" then Continue. Else, skip entire sub.
Private Sub SaveExternalCopy(ByVal Affiliate As String)
Application.ScreenUpdating = False
Application.DisplayAlerts = False
dt = Format(DateAdd("m", -1, Now), "mm.yyyy")
Dim mhoWb As Workbook
Set mhoWb = Workbooks("All_" & dt & " " & " Macro Enabled")
Dim mhoSheet As Worksheet
Set mhoSheet = Sheets("MHO")
mhoSheet.Activate
mhoSheet.UsedRange.AutoFilter field:=21, Criteria1:=Affiliate & " " & "Recon"
With mhoSheet
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
End With