+ Reply to Thread
Results 1 to 10 of 10

Run-time error '1004' on closing workbook

  1. #1
    Forum Contributor pipoliveira's Avatar
    Join Date
    08-09-2012
    Location
    Ireland
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    368

    Run-time error '1004' on closing workbook

    Dear all,

    I hope you are all well.

    I am having the following error:

    Run-time error '1004'
    Select method of Range class failed

    This error is on the Workbook.Close event in red:

    Please Login or Register  to view this content.
    This code copy information from a "Child" document to a "Master".

    I have a similar Master file with the exact codes (from other files) and it works perfectly closing the "Child" files without any errors.

    Any ideas why on this code it gives me the error?

    Your assistance will be highly appreciated.

    Best regards,
    Filipe Oliveira

  2. #2
    Forum Contributor HerryMarkowitz's Avatar
    Join Date
    09-10-2012
    Location
    Europe
    MS-Off Ver
    Office 2021 - Win10
    Posts
    1,019

    Re: Run-time error '1004' on closing workbook

    If you want to close wbAnalytics workbook you should use following code;
    Please Login or Register  to view this content.
    If you dont want to close wbAnalytics workbook you dont need any code. So, you can delete that line.
    Sub DontForgetThese()
         If Your thread includes any code Then Please use code tags...
         If Your thread has been solved Then Please mark as solved...
         If Anybody has helped to you Then Please add reputation...
    End Sub

  3. #3
    Forum Contributor pipoliveira's Avatar
    Join Date
    08-09-2012
    Location
    Ireland
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    368

    Re: Run-time error '1004' on closing workbook

    Hi Herry,
    Thanks for the reply.
    Your code is to close and save but I just want to close it without saving, that's why my code has "False".
    As mentioned, the same code works perfectly on other similar file but on this one I get that error code.
    Cheers,
    Filipe


    Sent from my iPhone using Tapatalk


    * If a reply solved or answered your query/question, you can add reputation to the person by clicking on the * Add Reputation
    * When question is resolved, please mark your thread as SOLVED


    Thanks and regards,
    Filipe Oliveira

  4. #4
    Forum Contributor HerryMarkowitz's Avatar
    Join Date
    09-10-2012
    Location
    Europe
    MS-Off Ver
    Office 2021 - Win10
    Posts
    1,019

    Re: Run-time error '1004' on closing workbook

    According the code you sent there is no changes workbook declaring wbAnalytics (C:\Users\PIPO\Documents\Analytics_DashBoard.xlsm).
    So, you dont need without saving thing.

    Do you want time saving?

  5. #5
    Forum Contributor pipoliveira's Avatar
    Join Date
    08-09-2012
    Location
    Ireland
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    368

    Re: Run-time error '1004' on closing workbook

    Hi Henry,
    Thanks for the reply.
    Even without changes, I have VBA codes on the "Open" and "before closes" events, meaning, only opening that file and closing, Excel asks if I was to save the changes.
    The main issue here is the "run-time error" that I am trying to understand why he does not accept it.
    I even tried your code and the same error occurred.
    Best regards,
    Filipe


    Sent from my iPhone using Tapatalk

  6. #6
    Forum Contributor HerryMarkowitz's Avatar
    Join Date
    09-10-2012
    Location
    Europe
    MS-Off Ver
    Office 2021 - Win10
    Posts
    1,019

    Re: Run-time error '1004' on closing workbook

    Change this,
    Please Login or Register  to view this content.
    to this,
    Please Login or Register  to view this content.


    or,
    Please Login or Register  to view this content.
    Last edited by HerryMarkowitz; 10-19-2014 at 07:13 PM.

  7. #7
    Forum Contributor pipoliveira's Avatar
    Join Date
    08-09-2012
    Location
    Ireland
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    368

    Re: Run-time error '1004' on closing workbook

    Hi Herry,
    Thanks for your reply and efforts.
    Unfortunately, I have the same errors again with your codes.
    There must be something giving that error as I have the same one (Different workbooks) and it works fine.
    Best regards,
    Filipe

  8. #8
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    Re: Run-time error '1004' on closing workbook

    You haven't posted the code in the BeforeClose event of that file. However, since you're not saving it, there doesn't seem to be a lot of need to run any code in it, so perhaps you could just use:
    Please Login or Register  to view this content.
    Everyone who confuses correlation and causation ends up dead.

  9. #9
    Forum Contributor pipoliveira's Avatar
    Join Date
    08-09-2012
    Location
    Ireland
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    368

    Re: Run-time error '1004' on closing workbook

    Hi romperstomper,

    You really hit the spot with the "Application.EnableEvents".

    Still don't understand what "events" were creating the Error but it solved it.

    Thanks a million once again.

    Really appreciated.

    Best regards,
    Filipe

  10. #10
    Forum Contributor HerryMarkowitz's Avatar
    Join Date
    09-10-2012
    Location
    Europe
    MS-Off Ver
    Office 2021 - Win10
    Posts
    1,019

    Re: Run-time error '1004' on closing workbook

    Dont forget sending us a reputation point.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Misterious Run-time error 1004 on Workbook Open
    By bagullo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-01-2014, 10:09 AM
  2. Run time error 1004 only immediately after opening protected workbook
    By JoeSkittles in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-25-2013, 11:02 AM
  3. Replies: 1
    Last Post: 09-16-2011, 05:59 AM
  4. Macro works in one workbook and not another - Run-Time Error 1004
    By vrobinson in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-10-2010, 07:30 PM
  5. Run-Time Error 1004 Shared Workbook
    By jmagdziarz in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-06-2005, 07:35 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1