Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default 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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default 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





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Does worksheet exist BB Ivan Excel Discussion (Misc queries) 1 January 29th 09 10:04 PM
Does Worksheet Exist BillCPA Excel Discussion (Misc queries) 5 April 19th 05 11:22 PM
Does a worksheet exist Kaval[_2_] Excel Programming 3 May 31st 04 07:21 AM
Does worksheet exist Robert S Excel Programming 3 May 18th 04 07:59 PM
check if a worksheet exist - VBA Warren Excel Programming 1 September 10th 03 05:02 AM


All times are GMT +1. The time now is 02:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"