Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Finding if Excel Sheet exists

Hi! Can anyone tell me how to find if an Excel Sheet is already created?
Is there an instruction in VBA to make this?
For example, to look for a value in a table we have HLookup, VLookup and
Lookup. Is there an instruction for Sheets?

Thanks.

Pedro


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,173
Default Finding if Excel Sheet exists

Pedro

You could iterate over the sheets collection

Sub IterateSheets()
Dim sht As Object
For Each sht In ActiveWorkbook.Sheets
If sht.Name = "Your Sheet Name" Then
MsgBox "Sheet found"
sht.Activate
Exit Sub
End If
Next sht
MsgBox "Sheet not found"
End Sub


--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
www.nickhodge.co.uk
HIS


"Pedro Miguel C. Silva" wrote in message
...
Hi! Can anyone tell me how to find if an Excel Sheet is already created?
Is there an instruction in VBA to make this?
For example, to look for a value in a table we have HLookup, VLookup and
Lookup. Is there an instruction for Sheets?

Thanks.

Pedro



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Finding if Excel Sheet exists


On Error Resume Next
Set ws = Worksheets("some sheet")
On Error Goto 0
If Not ws Is Nothing Then
MsgBox "sheet already exists"
End If

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Pedro Miguel C. Silva" wrote in message
...
Hi! Can anyone tell me how to find if an Excel Sheet is already created?
Is there an instruction in VBA to make this?
For example, to look for a value in a table we have HLookup, VLookup and
Lookup. Is there an instruction for Sheets?

Thanks.

Pedro




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
Deleting a sheet if it exists? drucey[_5_] Excel Programming 5 March 17th 06 02:53 PM
How can I programmatically check in Excel 2002 if a sheet exists? RangerTom Excel Programming 2 March 13th 06 08:33 PM
Sheet name already exists eddie_zoom Excel Discussion (Misc queries) 1 March 11th 05 02:53 PM
Check to see if sheet exists Steph[_3_] Excel Programming 4 September 22nd 04 12:47 AM
How can I know if a sheet exists ? Ben.C Excel Programming 3 December 29th 03 09:36 AM


All times are GMT +1. The time now is 05:21 AM.

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

About Us

"It's about Microsoft Excel"