Help Coding to Delete Certain Sheets

Copper Contributor
Hi,

Weekly I have to sort through 350 sheets and delete the ones that basically do not have any writing below cell 20. Is there a Macro code I could enter that deletes all worksheets that don’t have any values below row 20? If so could you help? This would take a lot of time off of this weekly task! Thanks!
1 Reply

@jimmyg123 How's this:

 

Sub DelSheets()
    Dim ws As Worksheet
    Dim i As Long
    
     For Each ws In ActiveWorkbook.Worksheets
        If Application.WorksheetFunction.CountA(ws.Range("21:1048576")) = 0 Then
            Application.DisplayAlerts = False
                ws.Delete
                i = i + 1
            Application.DisplayAlerts = True
        End If
    Next ws
    
    MsgBox i & " sheets were deleted", vbOKOnly + vbInformation, "Sheets deleted"
    
End Sub