Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Deleting a sheet if it exists? | Excel Programming | |||
How can I programmatically check in Excel 2002 if a sheet exists? | Excel Programming | |||
Sheet name already exists | Excel Discussion (Misc queries) | |||
Check to see if sheet exists | Excel Programming | |||
How can I know if a sheet exists ? | Excel Programming |