View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Sandy Mann Sandy Mann is offline
external usenet poster
 
Posts: 2,345
Default Deleting original sheets

One way would be to rename to original sheets, add the new sheets and then
delete all sheets renamed sheets as in this small macro:

Sub Deletesheets()
Application.ScreenUpdating = False

No = 1

For Each sh In Worksheets
sh.Name = "DeleteThis" & No
No = No + 1
Next sh

For x = 1 To 3
Sheets.Add
Next x

Application.DisplayAlerts = False

For Each sh In Worksheets
If Left(sh.Name, 10) = "DeleteThis" Then
sh.Delete
End If
Next sh

Application.DisplayAlerts = True

Application.ScreenUpdating = True
End Sub

Out of curiosity why are you counting the sheets using TotSheets then
copying the number to mycount? Why not use mycount in the first place?

--
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings


Replace @mailinator.com with @tiscali.co.uk


"Jeff Kelly" wrote in message
...
I have a workbook which has several original sheets of data

Using "TotSheets = Worksheets.Count' I count these sheets and call it
"mycount"
With a macro I add new sheets. How would I amend the macro at the end to
delete the original sheets.

72 years old and just learning so go easy on me.