Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

check if sheet exists ?

1 view
Skip to first unread message

Sammy

unread,
Jul 24, 2000, 3:00:00 AM7/24/00
to microsoft.public.excel.programming
Hi wise man :)

How do I check whether a sheet (by a certain name) already exists in the
current
workbook ??

Example:
I have a workbook with sheets called r1, r2,r3, etc. I want to find out
if r12 exists and if not create it (the latter proposes no problem however).

TIA

Sammy

Harald Staff

unread,
Jul 24, 2000, 3:00:00 AM7/24/00
to

Sammy

Try this function:

Function SheetExists(ShName As String) As Boolean
On Error Resume Next
SheetExists = Len(ActiveWorkbook.Sheets(ShName).Name)
End Function

Sub test()
MsgBox SheetExists("Sheet1")
MsgBox SheetExists("r1")
End Sub

Best wishes Harald

Sammy <Sa...@somewhere.nl> wrote in message
news:TLST15...@telestars.nl...

Sammy

unread,
Jul 25, 2000, 3:00:00 AM7/25/00
to microsoft.public.excel.programming

Harald Staff <harald...@eunet.no> schreef in berichtnieuws
#GDjWKb9$GA.195@cppssbbsa04...

Harald,

you're the man :)
thanks, works like a charm !

Sammy

0 new messages