Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello experts, I am a real novice so be patient please. I want to create a
script that allows me to check whether a particular worksheet exists in a workbook. At the moment my script assumes 'sheet 1' exists: [Sheets("Sheet 1").Delete] However, if the sheet has been manually deleted by the user my macro crashes. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Here's one way:
Dim WS As Worksheet On Error resume Next Set WS=Thisworkbook.Sheets("Sheet 1") 'You may want an Application.displayalerts=false/true If Not WS is Nothing then WS.delete On error goto 0 NickHK "NezRhodes" wrote in message ... Hello experts, I am a real novice so be patient please. I want to create a script that allows me to check whether a particular worksheet exists in a workbook. At the moment my script assumes 'sheet 1' exists: [Sheets("Sheet 1").Delete] However, if the sheet has been manually deleted by the user my macro crashes. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Nick, it is perfect & much appreciated
"NickHK" wrote: Here's one way: Dim WS As Worksheet On Error resume Next Set WS=Thisworkbook.Sheets("Sheet 1") 'You may want an Application.displayalerts=false/true If Not WS is Nothing then WS.delete On error goto 0 NickHK "NezRhodes" wrote in message ... Hello experts, I am a real novice so be patient please. I want to create a script that allows me to check whether a particular worksheet exists in a workbook. At the moment my script assumes 'sheet 1' exists: [Sheets("Sheet 1").Delete] However, if the sheet has been manually deleted by the user my macro crashes. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Check if file exists | Excel Discussion (Misc queries) | |||
How to check if a file exists in an ftp folder | Excel Discussion (Misc queries) | |||
check if file exists | Excel Programming | |||
How check for No/Cancel Button when SaveAs and file already exists? | Excel Programming | |||
check if a file exists / is open | Excel Programming |