ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   If a worksheet name is = to test then a msgbox appears (https://www.excelbanter.com/excel-discussion-misc-queries/61486-if-worksheet-name-%3D-test-then-msgbox-appears.html)

Vick

If a worksheet name is = to test then a msgbox appears
 
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

Dave Peterson

If a worksheet name is = to test then a msgbox appears
 
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



Vick wrote:

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


--

Dave Peterson


All times are GMT +1. The time now is 07:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com