Delete last sheet in workbook
Thanks Bernie. I was just using the default worksheet name (Sheet) originally
but when I changed the code to make the sheet name "Comments Summary" your
code worked perfectly.
Just one more question, how can I get the new sheet to be inserted as the
last sheet. It's currently created one before the last.
Thank you for all your help and expertise
Joe
"Bernie Deitrick" wrote:
Joe,
In your macro that creates the sheet, first delete the sheet before you try adding a new one, and
cotrol the sheet name.
Dim myS As Worksheet
Dim shtName As String
shtName = "Comments Summary"
On Error Resume Next
Application.DisplayAlerts = False
Worksheets(shtName).Delete
Application.DisplayAlerts = True
Worksheets.Add.Name = shtName
'Other code to put comments on sheet
HTH,
Bernie
MS Excel MVP
"Joe Gieder" wrote in message
...
First, thank you for looking at this post.
I have a macro that takes the cell comments from other sheets and creates a
summary sheet showing all of them. I'm constantly adding to the main sheets
and running this macro but every time I do I have to first delete the sheet
the macro created. Since the macro is called different tings every time it's
created I just say delete sheet xx. Since 95% of the time this sheet is at
the end is there any code that will automatically find and delete this sheet,
the sheet is always called "Sheet?". Also is there any code that I can use so
I don't have to hit OK when the message box pops up saying that the sheet
will permenantly be deleted?
Thanks again for you help
Joe
|