Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
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
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
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
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
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
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Deleting blank rows | Excel Worksheet Functions | |||
Is there a easy way to delete blank lines to clean up worksheets? | Excel Worksheet Functions | |||
Sumif to return a blank if sum range is blank | Excel Worksheet Functions | |||
Deleting blank spaces in cells | Excel Discussion (Misc queries) | |||
Eliminating Blank Cells From Lists on different worksheets | Excel Discussion (Misc queries) |