View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default check if worksheet is empty

One way

If Application.WorksheetFunction.CountA(sheets("Sheet 2").Cells) = 0 Then

If 0 there is no data on the sheet

Here is a working example to delete empty sheets

Sub Delete_EmptySheets()
Dim sh As Worksheet 'Ron de Bruin, programming, 2002-12-28
'On Error Resume Next 'possibility of all sheets blank
For Each sh In ThisWorkbook.Worksheets
If Application.WorksheetFunction.CountA(sh.Cells) = 0 Then
Application.DisplayAlerts = False
sh.Delete
Application.DisplayAlerts = True
End If
Next
'On Error goto 0 'Excel must have one sheet/workbook
End Sub



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Lynn" wrote in message oups.com...
Hi,
how can i check if worksheets labeled sheet2, sheet3 and sheet4 is
empty?
thanks