If a worksheet name is = to test then a msgbox appears

V

Vick

I'm looking for a macro that will display a msgbox if a worksheet is = to test.

For example, if the name of a sheet in a workbook is equal to test then
display msgbox saying sheet already exists.

Thanks

Vick
 
D

Dave Peterson

dim ws as worksheet
set ws = nothing
on error resume next
set ws = worksheets("test")
on error goto 0

if ws is nothing then
msgbox "doesn't exist"
else
msgbox "already exists"
end if
 
Top