create worksheet in a different, open workbook

I have the following that nicely checks whether the workbook is open, opens it.  thenchecks for a particular worksheet.  If it exists, it does give me the debug message I put in.  However, it if does not exist, it stops ath the worksheet add line with a subscript out of range error and I do not understand why.
Public Sub cmdRefreshActiveRatingData_Click()
'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
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")
    End If
    Workbooks("TEST_ClientActiveMasterTemplate.xls").Activate
    If fntDoesSheetExist(Workbooks("TEST_ClientActiveMasterTemplate.xls"), "DataSource") Then
        MsgBox "Yes, wks exists.", vbOKOnly
    Else
        MsgBox "No', wks does not exit.", vbOK
    'Get Subscript ouf of range here???
        Workbooks("TEST_ClientActiveMasterTemlate.xls").Worksheets.Add().Name = "DataSource"
    End If

End Sub

Open in new window

Sandra SmithRetiredAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Saqib Husain, SyedEngineerCommented:
change

        Workbooks("TEST_ClientActiveMasterTemlate.xls").Worksheets.Add().Name = "DataSource"

to

        Workbooks("TEST_ClientActiveMasterTemlate.xls").Worksheets.Add
       activesheet.Name = "DataSource"
0
Rory ArchibaldCommented:
You misspelled the workbook name. Change:
Workbooks("TEST_ClientActiveMasterTemlate.xls").Worksheets.Add().Name = "DataSource"

Open in new window

to:
Workbooks("TEST_ClientActiveMasterTemPlate.xls").Worksheets.Add().Name = "DataSource"

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
McOzCommented:
The workbook name you are referring to does not exist (misspelled):
'Get Subscript ouf of range here???
        Workbooks("TEST_ClientActiveMasterTemlate.xls").Worksheets.Add().Name = "DataSource"

Open in new window


Should be "TEST_ClientActiveMasterTemplate.xls"

Cheers!
0
Sandra SmithRetiredAuthor Commented:
Ok, rorya spotted it first!  I will undoubltely have more as this project has got to be on line MOnday and I am running on about 2 hours sleep a night.  I never even noticed this so simple problem.  Am posting a related questions on this project.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.