Sub deletesheetifcellSempty()
Application.DisplayAlerts = False
For Each sh In ActiveWorkbook.Worksheets
'if a12
'If Len(Application.Trim(sh.Range("a12"))) < 1 Then sh.Delete
'following line is ONE line for NO cell with ANYTHING, including header row
If Len(Application.Trim(sh.Cells.SpecialCells(xlCellTypeLastCell))) < 1 Then
sh.Delete
Next sh
Application.DisplayAlerts = True
End Sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"RU0824V" <(E-Mail Removed)> wrote in message
news:0FA3AF3C-B1B0-4ED6-BC4F-(E-Mail Removed)...
>I have ten sheets that my macro runs through...if there is no report data
>on
> a sheet, I want it to delete the sheet. The the cell to check for data is
> not
> going to be A12 on all sheets.
>
> --
> RU0824V
>
>
> "Don Guillett" wrote:
>
>> Are you trying to delete ONE sheet or any sheet in the workbook where
>> cell
>> a12 is empty?
>>
>> --
>> Don Guillett
>> Microsoft MVP Excel
>> SalesAid Software
>> (E-Mail Removed)
>> "RU0824V" <(E-Mail Removed)> wrote in message
>> news:4780DC8F-36A1-452F-B5DC-(E-Mail Removed)...
>> > Hello,
>> > I have figured out how to delete a sheet if a cell contains no data
>> > (although it does not seem to work consistently), but I cannot figure
>> > out
>> > how
>> > to stop the next section of code if the sheet is deleted. The code for
>> > the
>> > deleted sheet (if it had contained data) gets applied to the next
>> > worksheet.
>> >
>> > Here is what I have for the deletion...should this be followed by
>> > "else"
>> > or
>> > something? I am tyring to say "if cell A12 has no data, delete the
>> > worksheet"
>> >
>> > If IsEmpty(Range("A12")) Then SelectedSheets.Delete
>> >
>> > Thanks!
>> > Kathy
>> > --
>> > RU0824V
>>
>>