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 Delete Worksheets that only contain 2 rows of data

Hi joecrabtree

Basic example is this, there is no error check if all sheets have 2 rows or
less rows with data.
You can't delete all sheets in a workbook

Also the UsedRange can be bigger then you think
But see if this is working for you

Sub test()
Dim sh As Worksheet
For Each sh In ThisWorkbook.Worksheets
If sh.UsedRange.Rows.Count < 3 Then
Application.DisplayAlerts = False
sh.Delete
Application.DisplayAlerts = True
End If
Next sh
End Sub


--

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



"joecrabtree" wrote in message
ps.com...
To all,

I have a series of worksheets that I am performing calculations on.
However some of them only have two rows of data, and I don't want these
workskeets. How can I write a macro that will search through my
worksheets, and delete all of the ones with two rows of data or less?

I don't know if this is possible, but any help would be appreciated.

Thanks

Regards

Joseph Crabtree