Checking if a worksheet already exists...

J

JR

I want to check if a worksheet already exists based on its tab name
(for example, "Test"). If it exists, I want to delete it, then add a
blank worksheet with the same name. Is there a simple way of doing
this?

Thanks!
JR
 
F

Frank Kabel

Hi
you may try something like the following

sub foo()
dim wks as worksheet
on error resume next
set wks = activeworkbook.worksheets("Test")
on error goto 0
if not wks is nothing then
application.displayalerts=false
wks.delete
application.displayalerts=True
end if
'insert your new sheet
end sub
 
Top