I have some code to delete empty sheets in a workbook but I'm not sure how to modify it to delete the sheets only if they have no data below row 1. I have a header row and if no data is populated to the sheet(s) I want to be able to run this macro in the workbook to be able to delete those blank sheets. Here is the code I am currently using:
Sub delete()
Application.DisplayAlerts = False
Dim sh As Worksheet
For Each sh In Sheets
If IsEmpty(sh.UsedRange) Then sh.delete
Next
Application.DisplayAlerts = True
End Sub
Sub delete()
Application.DisplayAlerts = False
Dim sh As Worksheet
For Each sh In Sheets
If IsEmpty(sh.UsedRange) Then sh.delete
Next
Application.DisplayAlerts = True
End Sub
Last edited: