Home |
Search |
Today's Posts |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
application.displayalerts = false
on error resume next worksheets("Myname").delete on error goto 0 application.displayalerts = true If the sheet doesn't exist, then the error is ignored. (The .displayalerts stuff stops the confirmation dialog from showing up.) ===== Chip Pearson posted this function: Function WorksheetExists(SheetName As Variant, _ Optional WhichBook As Workbook) As Boolean 'from Chip Pearson Dim WB As Workbook Set WB = IIf(WhichBook Is Nothing, ThisWorkbook, WhichBook) On Error Resume Next WorksheetExists = CBool(Len(WB.Worksheets(SheetName).Name) 0) End Function 'and you can use it like: .... if worksheetexists("myname",activeworkbook) then application.displayalerts = false worksheets("Myname").delete application.displayalerts = true end if Art Parra wrote: how do I find out if a sheet exist to delete it? I've tried: if not isnull(sheets("myname")) then sheets("myname").delete end if thanks, -- Dave Peterson |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
VBA: Make a new sheet if it doesn't exist | Excel Discussion (Misc queries) | |||
VBA, Make a new sheet if it doesn't exist | Excel Discussion (Misc queries) | |||
Does the sheet exist? | Excel Programming | |||
test if a sheet exist (with the name) ? | Excel Programming | |||
Does sheet exist? | Excel Programming |