C
ChuckM
I check for the existance of a worksheet in my workbook...if it exists
I want to delete it. I run through a list of sheet names and delete
them if they exist. This works.... e.g. getting a positive response
that the sheet exists. But I am also getting a positive response when
the sheet does not exist.
Dim SheetExists As Boolean
For n = 1 To 6
On Error Resume Next
SheetExists = Sheets(sheetname(n)).name = sheetname(n)
On Error GoTo 0
If SheetExists Then
' delete it if it exists"
Sheets(sheetname(n)).Select
Application.DisplayAlerts = False
Worksheets(sheetname(n)).Delete
Application.DisplayAlerts = True
Else
' do nothing
End If
Next n
I want to delete it. I run through a list of sheet names and delete
them if they exist. This works.... e.g. getting a positive response
that the sheet exists. But I am also getting a positive response when
the sheet does not exist.
Dim SheetExists As Boolean
For n = 1 To 6
On Error Resume Next
SheetExists = Sheets(sheetname(n)).name = sheetname(n)
On Error GoTo 0
If SheetExists Then
' delete it if it exists"
Sheets(sheetname(n)).Select
Application.DisplayAlerts = False
Worksheets(sheetname(n)).Delete
Application.DisplayAlerts = True
Else
' do nothing
End If
Next n