Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 111
Default Delete Worksheets that only contain 2 rows of data

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete all rows below certain value on multiple worksheets? [email protected] Excel Discussion (Misc queries) 1 January 4th 08 05:51 PM
compare two worksheets and delete rows [email protected] Excel Programming 6 May 27th 06 12:41 AM
Add or Delete Rows in Protected worksheets NH Excel Discussion (Misc queries) 0 March 16th 06 05:15 PM
delete rows from multiple worksheets dckrause Excel Worksheet Functions 1 June 1st 05 03:24 AM
Using VBA to delete certain worksheets rows avilla Excel Programming 1 September 7th 04 04:34 PM


All times are GMT +1. The time now is 11:03 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"