If Worksheets("Test") Exists Then Delete It

  • Thread starter Thread starter Don
  • Start date Start date
D

Don

Hi,

I want to do the above, but just can't work out how to do
it. If anyone has a piece of code that would work, I would
be very grateful.

Exists does not seem to work with the Worsheets.Item
object.

Don.
 
Try this:


Public Function ShExists(ShName As String) As Boolean
Dim WS As Worksheet

For Each WS In Workbooks _
(ActiveWorkbook.Name).Worksheets
If WS.Name = ShName Then
'If that sheet name exists
ShExists = True
Exit Function
End If

Next
ShExists = False
End Function

Abdul Salam
 
Back
Top