Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Lvenom
 
Posts: n/a
Default Deleting blank worksheets


My data is imported from a seperate program and the other program
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 3
blank worksheets. Is there any way to right a macro to delete only the
blank worksheets? Thank you for any help provided.


--
Lvenom
------------------------------------------------------------------------
Lvenom's Profile: http://www.excelforum.com/member.php...o&userid=35358
View this thread: http://www.excelforum.com/showthread...hreadid=552065

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
tony h
 
Posts: n/a
Default Deleting blank worksheets


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 helps


--
tony h
------------------------------------------------------------------------
tony h's Profile: http://www.excelforum.com/member.php...o&userid=21074
View this thread: http://www.excelforum.com/showthread...hreadid=552065

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Lvenom
 
Posts: n/a
Default Deleting blank worksheets


Thank you for the quick response. I tried the code supplied but I get an
error at

wks.Delete
Doesn't recognize this I guess. I am working with Excel 97 so maybe I
just have a tired program....


--
Lvenom
------------------------------------------------------------------------
Lvenom's Profile: http://www.excelforum.com/member.php...o&userid=35358
View this thread: http://www.excelforum.com/showthread...hreadid=552065

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
tony h
 
Posts: n/a
Default Deleting blank worksheets


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


--
tony h
------------------------------------------------------------------------
tony h's Profile: http://www.excelforum.com/member.php...o&userid=21074
View this thread: http://www.excelforum.com/showthread...hreadid=552065

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
Deleting blank rows Yvette Excel Worksheet Functions 3 June 9th 06 10:30 AM
Is there a easy way to delete blank lines to clean up worksheets? jdf5 Excel Worksheet Functions 2 June 4th 06 06:05 PM
Sumif to return a blank if sum range is blank [email protected] Excel Worksheet Functions 3 May 25th 06 10:25 AM
Deleting blank spaces in cells Mr Gow Excel Discussion (Misc queries) 4 May 17th 06 02:06 PM
Eliminating Blank Cells From Lists on different worksheets Tim Excel Discussion (Misc queries) 3 November 3rd 05 12:37 PM


All times are GMT +1. The time now is 02:13 AM.

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

About Us

"It's about Microsoft Excel"