View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
smw226 via OfficeKB.com smw226 via OfficeKB.com is offline
external usenet poster
 
Posts: 98
Default Excel 2002 : How to reduce the number of unused worksheet ?

Forgot to mention,

As with all untested code, please run this on a copy of your live spreadsheet.


Thanks,

Simon

smw226 wrote:
Hi Low,

This code will look at every one of your worksheets and delete them if they
are blank. Of course, the IF criteria can be amanded to look for something
else if you like

HTH

Simon

------------------------------------------------------------------------------
-----

Sub wkbk_cleanup()
Dim wkbk As Worksheet

Application.ScreenUpdating = False
Application.DisplayAlerts = False

For Each wkbk In ActiveWorkbook.Worksheets

'Select the worksheet
wkbk.Select

'Look for the last used cell.
ActiveCell.SpecialCells(xlLastCell).Select

'If its A1 then the sheet is blank and can be deleted.
'Amend the test as required.

If ActiveCell.Address = "$A$1" Then
wkbk.Delete
End If

Next wkbk

End Sub

------------------------------------------------------------------------------
-------

Dear Sir,

[quoted text clipped - 13 lines]

Low



--
--------------------
Simon - UK

Email at simon22mports [ a t ] hot mail [ d ot ]com

Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...excel/200704/1