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

G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top