Hi Jim,
Thank you.
I added the workbook argument but omitted the intended qualification.
As you correctly indicate, without the qualification, the function operates
on the active workbook.
---
Regards,
Norman
"Jim Thomlinson" wrote in message
...
Does that code function correctly... I like the optional workbook argument
but I think you need to change the line.
SheetExists = CBool(Len(sheets(sName).Name))
to
SheetExists = CBool(Len(wb.sheets(sName).Name))
Otherwise this function will look at the active workbook won't it?
--
HTH...
Jim Thomlinson
"Norman Jones" wrote:
Hi Raman325,
Try:
Function SheetExists(sName As String, _
Optional ByVal wb As Workbook) As Boolean
On Error Resume Next
If wb Is Nothing Then Set wb = ActiveWorkbook
SheetExists = CBool(Len(sheets(sName).Name))
End Function
---
Regards,
Norman
"Raman325" wrote
in
message ...
What is the best way to check whether a given worksheet exists? For
example, I would like to know whether the "Week 1" worksheet exists
without throwing an error to the user. Thanks in advance for your help.
--
Raman325
------------------------------------------------------------------------
Raman325's Profile:
http://www.excelforum.com/member.php...o&userid=24748
View this thread:
http://www.excelforum.com/showthread...hreadid=397253