View Full Version : [SOLVED:] Delete worksheets with blank cell
I have a file with multiple worksheet and I need a code that will delete only worksheet that cell C2 is blank/empty. In addition, the code will not delete constant worksheets named "Master", "Table of Contents", "Lookup", "Lookup Names", or "Names"
Thank you for any and all help
Paul_Hossler
10-17-2021, 05:07 PM
Not tested, but probably something like this
Option Explicit
'I have a file with multiple worksheet and I need a code that will delete only worksheets
'that have cell C2 is blank/empty. In addition, the code will not delete constant worksheets
'named "Master", "Table of Contents", "Lookup", "Lookup Names", or "Names"
Sub DeleteSomeWorksheets()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
Select Case ws.Name
Case "Master", "Table of Contents", "Lookup", "Lookup Names", "Names"
Case Else
If Len(ws.Range("C2").Value) = 0 Then
Application.DisplayAlerts = False
ws.Delete
Application.DisplayAlerts = True
End If
End Select
Next
End Sub
Works Perfect,
Thank you so much!
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.