+ Reply to Thread
Results 1 to 4 of 4

VBA code as presented keeps crashing

  1. #1
    Registered User
    Join Date
    01-23-2019
    Location
    Belo Horizonte, Brazil
    MS-Off Ver
    Windows 2016
    Posts
    49

    VBA code as presented keeps crashing

    Howdy

    I'm not a VBA expert, and what I compiled is mainly from reading through the internet. And code keeps crashing the excel midway through the execution.
    So here it goes the info about it

    The goal of the code:
    * To access 288 .xlsx files one by one
    * Copy a specific range considering criteria in a filter
    * Paste the copied information into a consolidated .xlsx file

    The problem: It keeps crashing randomly

    The workaround i found: Cut the execution in blocks of 30-40 .xlsx files, only then will it work.

    Please Login or Register  to view this content.

    Can you guys shed some light in this?
    What can i do to improve it or clean it?
    What could be the cause of the problem of the random crashes?

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,447

    Re: VBA code as presented keeps crashing

    On which line does it crash when running the macro step by step ( with the F8 button)?

  3. #3
    Registered User
    Join Date
    01-23-2019
    Location
    Belo Horizonte, Brazil
    MS-Off Ver
    Windows 2016
    Posts
    49

    Re: VBA code as presented keeps crashing

    Quote Originally Posted by Pepe Le Mokko View Post
    On which line does it crash when running the macro step by step ( with the F8 button)?
    Well, it doesn't.
    When i run it through step by step it doesn't crash.
    I think is something related to the memory demanding method of copy+paste

    I've developed an entirely different code that loops through every line in each of those 288 .xlsx files to bring out the needed rows, but it takes forever.

  4. #4
    Valued Forum Contributor
    Join Date
    09-30-2018
    Location
    Vlaams Brabant Belgium
    MS-Off Ver
    365
    Posts
    456

    Re: VBA code as presented keeps crashing

    Hi,

    Maybe move the 'Dim UltimaLinha As Integer' outside the loop
    and 'set ArquivoAberto = nothing' so its really empty
    remove the 'ArquivoConsolidado.Save' after the if then else where it already is saved in both cases

    Grtz

+ 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. Excel Crashing when running code
    By ShakJames in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-07-2017, 11:41 AM
  2. Worksheet_Change Code Crashing
    By f15e in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-16-2017, 10:58 PM
  3. Code running twice and crashing after workbook saves
    By ajam in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-22-2016, 05:15 PM
  4. [SOLVED] Code is crashing, how can I make this work?
    By liquidmettle in forum Excel Programming / VBA / Macros
    Replies: 27
    Last Post: 01-08-2016, 01:28 AM
  5. Excel crashing when trying to view code before macro run; not crashing after first run
    By goonerforlyf in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-21-2015, 05:27 PM
  6. VBA - Run code without crashing
    By DesAjax in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-23-2014, 01:11 PM

Tags for this Thread

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