Inserting and deleting worksheets

C

ChuckM

I have 2 questions.

1. how to insert a worksheet and rename it
e.g. I want to add/insert a worksheet and name it "Summary"

2. how to detect the existance of a worksheet by name and then delete
it if it exists.
e.g. If a worksheet with the name "Data" exists...then delete
it.

thanks
chuck
 
G

Gord Dibben

Chuck

Sub alskdj()
For Each wkSht In Worksheets
With wkSht
If .Name = "Summary" Then
Application.DisplayAlerts = False
Sheets("Data").Delete
End If
End With
Next
Application.DisplayAlerts = True
End Sub


Sub zmxncbv()
Worksheets.Add.Name = "Summary"
End Sub

Gord Dibben Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top