![]() |
Checking whether a worksheet exist or not
hie, How do i check whether the worksheet by the name of "results" exist o not? thankx in advanc -- ajitpalsingh20 ----------------------------------------------------------------------- ajitpalsingh200's Profile: http://www.excelforum.com/member.php...fo&userid=1615 View this thread: http://www.excelforum.com/showthread.php?threadid=27651 |
Checking whether a worksheet exist or not
For Each sht In Worksheets if sht.Name = "results" then msgbox "results exists" exit function end if Next - Manges -- mangesh_yada ----------------------------------------------------------------------- mangesh_yadav's Profile: http://www.excelforum.com/member.php...fo&userid=1047 View this thread: http://www.excelforum.com/showthread.php?threadid=27651 |
Checking whether a worksheet exist or not
try this:
Sub CheckSheet() On Error GoTo erHandler If ThisWorkbook.Sheets("results").Index 0 Then MsgBox "Sheet1 exists" Exit Sub End If erHandler: MsgBox "Sheet1 does not exist" End Sub KL "ajitpalsingh200" wrote in message ... hie, How do i check whether the worksheet by the name of "results" exist or not? thankx in advance -- ajitpalsingh200 ------------------------------------------------------------------------ ajitpalsingh200's Profile: http://www.excelforum.com/member.php...o&userid=16150 View this thread: http://www.excelforum.com/showthread...hreadid=276513 |
Checking whether a worksheet exist or not
sorry, here is the correct version:
Sub CheckSheet() On Error GoTo erHandler If ThisWorkbook.Sheets("results").Index 0 Then MsgBox "sheet Results exists" Exit Sub erHandler: MsgBox "sheet Results does not exist" End Sub "KL" wrote in message ... try this: Sub CheckSheet() On Error GoTo erHandler If ThisWorkbook.Sheets("results").Index 0 Then MsgBox "Sheet1 exists" Exit Sub End If erHandler: MsgBox "Sheet1 does not exist" End Sub KL "ajitpalsingh200" wrote in message ... hie, How do i check whether the worksheet by the name of "results" exist or not? thankx in advance -- ajitpalsingh200 ------------------------------------------------------------------------ ajitpalsingh200's Profile: http://www.excelforum.com/member.php...o&userid=16150 View this thread: http://www.excelforum.com/showthread...hreadid=276513 |
Checking whether a worksheet exist or not
ANother option
Check with If SheetExists("results") Then ... '----------------------------------------------------------------- Function SheetExists(Sh As String, _ Optional wb As Workbook) As Boolean '----------------------------------------------------------------- Dim oWs As Worksheet If wb Is Nothing Then Set wb = ActiveWorkbook On Error Resume Next SheetExists = CBool(Not wb.Worksheets(Sh) Is Nothing) On Error GoTo 0 End Function -- HTH RP (remove nothere from the email address if mailing direct) "ajitpalsingh200" wrote in message ... hie, How do i check whether the worksheet by the name of "results" exist or not? thankx in advance -- ajitpalsingh200 ------------------------------------------------------------------------ ajitpalsingh200's Profile: http://www.excelforum.com/member.php...o&userid=16150 View this thread: http://www.excelforum.com/showthread...hreadid=276513 |
All times are GMT +1. The time now is 05:27 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com