Solved

find sheet named ......

Posted on 2015-01-27
3
70 Views
Last Modified: 2015-01-28
Can an expert provide vba code that look to see if a sheet exists, if it does continue with my code and if not end sub

So I want to say:

look for sheet named Spain if it exists continue if it does not exist stop

Thanks
0
Comment
Question by:Jagwarman
3 Comments
 
LVL 48

Accepted Solution

by:
Rgonzo1971 earned 200 total points
Comment Utility
Hi,

pls try
On Error Resume Next
Set sh = ActiveWorkbook.Sheets("Spain")
On Error GoTo 0
If IsEmpty(sh) Then Exit Sub

Open in new window

Regards
0
 
LVL 85

Assisted Solution

by:Rory Archibald
Rory Archibald earned 200 total points
Comment Utility
As an alternative:

If Not Evaluate("ISREF(Spain!A1)") Then Exit Sub

Open in new window

0
 
LVL 7

Assisted Solution

by:slubek
slubek earned 100 total points
Comment Utility
Function WorksheetExists(ByVal WorksheetName As String) As Boolean
Dim Sht As Worksheet
    For Each Sht In ThisWorkbook.Worksheets
        If Application.Proper(Sht.Name) = Application.Proper(WorksheetName) Then
            WorksheetExists = True
            Exit Function
        End If
    Next Sht
    WorksheetExists = False
End Function

...
if WorksheetExists("Spain") then ...

Open in new window

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Dealing with unintended Excel Active-X resizing quirks (VBA code simulates "self correction") David Miller (dlmille) Intro Not everyone is a fan of Active-X controls in spreadsheets (as opposed to the UserForm approach, the older Form controls …
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now