Delete sheet without prompt
Here is one way for the second part
iNext = Activeworkbook.Worksheets.Count + 1
Do Until Not SheetExists("Sheet" & iNext)
iNext = iNext + 1
Loop
Woeksheets.Add.Name = "Sheet" & iNext
Function SheetExists(Filename As String)
Dim oSh As Worksheet
On Error Resume Next
Set oSh = ActiveWorkbook.Worksheets(Filename)
On Error GoTo 0
SheetExists = Not oSh Is Nothing
End Function
--
HTH
Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
"chad" wrote in message
...
How can I delete a sheet without a message box prompting for the user to
confirm the deletion of the sheet? Also, is there a way to rename a sheet
without it defaulting to "sheet1" or the next number? In other words, if
"sheet1" already exists when I add a new sheet it will default to "sheet2"
and the following code will generatte an error.
Sheets("Import").Select
ActiveWindow.SelectedSheets.Delete
Sheets.Add
Sheets("Sheet1").Name = "Import"
Thanks
|