Link to home
Start Free TrialLog in
Avatar of Sandra Smith
Sandra SmithFlag for United States of America

asked on

Check if worksheet exists in another open workbook

My process so far checks to see if another workbooks is open and it if is not, then it opens.  Ok, so far so good.  However, next I need to check in this workbook if the worksheet "DataSource" exists and if not, create it.  I can't get pass the checking for the worksheet.   It errors out at the If Len(.worksheets("DataSource).Name > 0 Then statement.
'First check to see if the file is open and if not, then open.  Then check to see if the
'worksheet DataSource exists in the workbook and if not, create it.  Then query the
'ActiveMasterTempate DataSource worksheet to bring in the Rating data
Dim wks As Worksheet
Dim strColumnHeaders()  As String
strFileExportPathSumm = ThisWorkbook.Worksheets("Settings").Range("FOLDER_PATH_SUMMARY") ' Summary Reports/General Folder, Range name on Settings worksheet, Settings!$I$5

    If Not fntIsWbkOpen("TEST_ClientActiveMasterTemplate.xls") Then
       Application.Workbooks.Open strFileExportPathSumm & "TEST_ClientActiveMasterTemplate.xls", 2
    End If
        With Workbooks("TEST_ClientActiveMasterTemplate.xls")
            .Activate
            If Len(.Worksheets("DataSource").Name) > 0 Then 'Subscrpt out of range nere
                MsgBox "Yes"
            Else
                MsgBox "No"
            End If
        End With

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of zorvek (Kevin Jones)
zorvek (Kevin Jones)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sandra Smith

ASKER

That answered that quite nicely.  Thank you.

Sandra