ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete Sheets (https://www.excelbanter.com/excel-programming/351946-delete-sheets.html)

STEVEB

Delete Sheets
 

Hi

Does anyone have any suggestions for deleting an entire sheet in
workbook if Cell A1 in the Sheet is blank?

Thank

--
STEVE
-----------------------------------------------------------------------
STEVEB's Profile: http://www.excelforum.com/member.php...nfo&userid=187
View this thread: http://www.excelforum.com/showthread.php?threadid=50679


Chip Pearson

Delete Sheets
 
Try

If Range("A1").Value = "" Then
Application.DisplayAlerts = False
Worksheets("Sheet1").Delete
Application.DisplayAlerts = True
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"STEVEB"
wrote in message
...

Hi

Does anyone have any suggestions for deleting an entire sheet
in a
workbook if Cell A1 in the Sheet is blank?

Thanks


--
STEVEB
------------------------------------------------------------------------
STEVEB's Profile:
http://www.excelforum.com/member.php...fo&userid=1872
View this thread:
http://www.excelforum.com/showthread...hreadid=506797




Glen[_5_]

Delete Sheets
 
Sub DelSheet()
Dim wb As Workbook
Dim ws As Worksheet
Dim a As Variant

Set wb = ActiveWorkbook
Set ws = wb.Worksheets("sheet1")
a = Range("A1").Value
'Put this in a for loop to change wb or ws as necessary
If a = "" Then
ws.Delete
Else
Set ws = wb.Worksheets("sheet2")
End If

End Sub


Bruno Campanini[_3_]

Delete Sheets
 
"STEVEB" wrote in
message ...

One more way:
---------------------------------
Sub Button14_Click()
Application.DisplayAlerts = False
If IsEmpty([Sheet7!A1]) Then
Sheets("Sheet7").Delete
End If

End Sub
------------------------------

Bruno



STEVEB

Delete Sheets
 

Thanks everyone,

Everything worked great! I appreciate your help

--
STEVE
-----------------------------------------------------------------------
STEVEB's Profile: http://www.excelforum.com/member.php...nfo&userid=187
View this thread: http://www.excelforum.com/showthread.php?threadid=50679



All times are GMT +1. The time now is 09:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com