Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Delete sheet without prompt
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").Selec ActiveWindow.SelectedSheets.Delet Sheets.Ad Sheets("Sheet1").Name = "Import Thank |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Delete sheet without prompt
Hi chad
Application.DisplayAlerts = False 'delete code Application.DisplayAlerts = True This example will not give a error if it exist On Error Resume Next Sheets("Sheet1").Name = "Import" On Error GoTo 0 -- Regards Ron de Bruin http://www.rondebruin.nl "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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Delete sheet without prompt
Thanks all.
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Delete ROW on Sheet#1 corupts data on Sheet#2 | Excel Worksheet Functions | |||
Delete values in sheet 2 that arre found in sheet 1 | Excel Discussion (Misc queries) | |||
Unwanted Prompt When Saving a Protected Sheet in 2007 | Excel Discussion (Misc queries) | |||
How do I disable save prompt when exiting a sheet? | Excel Discussion (Misc queries) | |||
Delete rows from one sheet containing deatils on the second sheet | New Users to Excel |