PC Review


Reply
Thread Tools Rate Thread

Delete Worksheets that only contain 2 rows of data

 
 
joecrabtree
Guest
Posts: n/a
 
      4th Dec 2006
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

 
Reply With Quote
 
 
 
 
Ron de Bruin
Guest
Posts: n/a
 
      4th Dec 2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete all rows below certain value on multiple worksheets? smduello@gmail.com Microsoft Excel Misc 3 4th Jan 2008 06:30 PM
Delete rows at the same time from selected worksheets =?Utf-8?B?Rmlsbw==?= Microsoft Excel Programming 3 5th May 2007 02:41 PM
compare two worksheets and delete rows mike.wilson8@comcast.net Microsoft Excel Programming 6 27th May 2006 12:41 AM
Add or Delete Rows in Protected worksheets =?Utf-8?B?Tkg=?= Microsoft Excel Misc 0 16th Mar 2006 05:15 PM
delete rows from multiple worksheets =?Utf-8?B?ZGNrcmF1c2U=?= Microsoft Excel Worksheet Functions 1 1st Jun 2005 03:24 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:15 PM.