New Tab Debug

D

Dave Peterson

dim testwks as worksheet
dim WksName as string

wksname = format(dateserial(2009,12,25), "yyyymmdd")

set testwks = nothing
on error resume next
set testwks = worksheets(wksname)
on error resume next

if testwks is nothing then
'doesn't exist, so create it
set testwks = worksheets.add
testwks.name = wksname
end if

with testwks 'either the existing one or the one created.
.range("A1").value = "hi there"
end with

(Untested, uncompiled. Watch for typos.)
 
M

Microsoft Communities

Currently I am creating a new tab using a date formula (in a macro). I would
like it to check if the tab exists and if so, go to that sheet and do
whatever. It it does not exist create it and go to it and do whatever.
 
Top