Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sheet Exists Problem

Status
Not open for further replies.

robcarr

Programmer
May 15, 2002
633
GB
Hi,

having a problem with a sheet exists function

i have this

f WksExists(stsht) Then

Else

End If


Function WksExists(wksName As String) As Boolean
On Error Resume Next
WksExists = CBool(Len(Worksheets(wksName).Name) > 0)
End Function

i get a subscript out of range.

shsht is a value from a loop that the if is in.



Hope this is of use, Rob.[yoda]
 
The quick solution is to change error trapping settings to 'break on unhandled errors' (Tools>Options =>'General' tab). However, this depends on local user settings. An alternative - create For Each...Next loop and compare sheet names.

combo
 
just figured it out, not sure why it was not set, must have been playing with something before.

Hope this is of use, Rob.[yoda]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top