Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Worksheet Functions / June 2006

Tip: Looking for answers? Try searching our database.

Deleting blank worksheets

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lvenom - 14 Jun 2006 23:41 GMT
My data is imported from a seperate program and the other progra
automatically opens a new work book when the import starts. My problem
the data only resides on the first worksheet and then there are 2 to
blank worksheets. Is there any way to right a macro to delete only th
blank worksheets? Thank you for any help provided
tony h - 15 Jun 2006 00:01 GMT
try

Sub a()
Dim rng As Range
Dim wks As Worksheet

Application.DisplayAlerts = False
For Each wks In ThisWorkbook.Worksheets()
If wks.UsedRange.Cells.Count <= 1 Then
wks.Delete
End If
Next
Application.DisplayAlerts = True

End Sub

note that the count test is against a value of 1

Hope this help
Lvenom - 15 Jun 2006 00:11 GMT
Thank you for the quick response. I tried the code supplied but I get a
error at

wks.Delete
Doesn't recognize this I guess. I am working with Excel 97 so maybe
just have a tired program...
tony h - 15 Jun 2006 00:28 GMT
The code does assume you have data on at least one worksheet. If none
have data on them then it will error on trying to delete the last
sheet.

So import your data then run the macro

Signature

tony h

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.