Deleting original sheets
OK Jeff, after hashing things out with Dave, the following should do the
trick unless your new pages are interspersed. As long as they are either all
before, or all after the originals, one of the two versions below will work.
If the new sheets are inserted before the originals:
Application.DisplayAlerts = False
Dim Sh As Worksheet
'count new sheets
x = ThisWorkbook.Sheets.Count - myCount
For Each Sh In ThisWorkbook.Sheets
If Sh.Index x Then
Sh.Delete
End If
Next
Application.DisplayAlerts = True
If the new sheets are inserted after the originals:
Application.DisplayAlerts = False
Dim Sh As Worksheet
For Each Sh In ThisWorkbook.Sheets
If Sh.Index <= myCount Then
Sh.Delete
End If
Next
Application.DisplayAlerts = True
"Jeff Kelly" wrote:
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.
|