Sub run()
On Error GoTo 999
Sheets("sheet1").Select
Exit Sub
999
Sheets.Add
ActiveSheet.Name = "sheet1"
End Sub
On Error Resume Next
MkDir "D:\xxx" ' 不存在就建一个,已存在则跳到下一句
function CheckSheet(sName as string) as boolean
dim ws as worksheet
on error goto TT
set ws=thisworkbook.worksheets(sName)
checksheet=ture 'worksheet exists
exit function
TT:
checksheet=false 'no sheet found
end function
function AddSheet()
dim ws as worksheet,sKey as string
skey="kk"
if checksheet(skey)=false then
set ws=thisworkbook.worksheet.add
ws.name=skey
end if
end function