Forum Discussion

Georgina Sothcott-Gilson's avatar
Georgina Sothcott-Gilson
Copper Contributor
May 24, 2018

Need help with VBA - error 424 object required

Hi, 

 

I am creating a big report - that amalgamates about 9 different reports from our system.

T do this I have created a VBA to run all of these reports into the one spreadsheet, where I can then create a Macro that puts all of this into the end product/report. 

 

The issue i'm having is that the VBA won't run and presents as 'error 424 Object required'.

 

When I press 'Debug' it takes me to the coding and highlights in yellow the workbook line - where I am specifying what file I need the VBA to open and paste the data into. 

 

Workbook.Open Filename:="\\thebridgeeastmidlands-my.sharepoint.com@SSL\personal\data_thebridge-eastmidlands_org_uk\Business Services\CST\16. Communications\14. Reporting\Quaterly Reports\MASTER REPORT"

 

Attached workbook - can anyone help solve why this won't work?

 

Kindest Regards, 

Georgina Sothcott-Gilson

5 Replies

  • Matt Mickle's avatar
    Matt Mickle
    Bronze Contributor

    I think the VBA command is actually Workbooks.Open not Workbook.open

     

     

    Try using this syntax instead. You will also need to specify a file extension.  So maybe this:

     

    Workbooks.Open Filename:="\\thebridgeeastmidlands-my.sharepoint.com@SSL\personal\data_thebridge-eastmidlands_org_uk\Business Services\CST\16. Communications\14. Reporting\Quaterly Reports\MASTER REPORT.xlsx
    • Georgina Sothcott-Gilson's avatar
      Georgina Sothcott-Gilson
      Copper Contributor

      Thank you so much for replying, it worked! 

      But.... now it is saying 'Run-time error '9': Subscript out of range' 

       

      Are you able to help with this one too?

       

      Thank you so much in advance. 

      • Georgina Sothcott-Gilson's avatar
        Georgina Sothcott-Gilson
        Copper Contributor

        This line is the issue:

        Worksheets("DATA Referal numbers").Select

         

        Full:

        Sub AccumlatedDataforQuaterlyReports()
        Dim LastRow As Integer, i As Integer, erow As Integer
        LastRow = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row

        For i = 2 To LastRow

        Range(Cells(i, 1), Cells(i, 13)).Select
        Selection.Copy
        Workbooks.Open Filename:="\\thebridgeeastmidlands-my.sharepoint.com@SSL\personal\data_thebridge-eastmidlands_org_uk\Business Services\CST\16. Communications\14. Reporting\Quaterly Reports\MASTER REPORT.xlsx"
        Worksheets("DATA Referal numbers").Select
        erow = AactiveSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
        ActiveSheet.Cells(erow, 1).Select
        ActiveSheet.Paste
        ActiveWorkbook.Save
        ActiveWorkbook.Close
        Next i
        End Sub

Resources