+ Reply to Thread
Results 1 to 4 of 4

Most Efficient Way To Pull Data From Multiple Files

  1. #1
    Registered User
    Join Date
    04-12-2019
    Location
    Manchester
    MS-Off Ver
    2016
    Posts
    20

    Most Efficient Way To Pull Data From Multiple Files

    Hi,

    I currently have a Macro that pulls the data from work books in a file.

    The only issue is that it runs very slowly. See Excerpt below there is a lot more data it copies.


    Please Login or Register  to view this content.
    The reason for the Else if, is because the data in the file could shift down depending on the inputs. So if there is text in cell that determines what data needs to be picked up.

    I've also reduced the number of inputs here. There is 4 Else if statements and also about 170 cells I am picking the info from and pasting into a summary sheet.

    Any help would be greatly appreciated.

    Thanks and regards
    Christian

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Most Efficient Way To Pull Data From Multiple Files

    Hi there,

    See if the following code gets you moving in the right direction - instead of performing Copy / PasteSpecial operations it takes the values in the range to be copied and assigns them to an array, and then assigns the values in the array to the range into which the PasteSpecial operation would have been performed. In general this is a more efficient means of copying data.

    Please Login or Register  to view this content.

    Hope this helps - please let me know how you get on.

    Regards,

    Greg M

  3. #3
    Registered User
    Join Date
    04-12-2019
    Location
    Manchester
    MS-Off Ver
    2016
    Posts
    20

    Re: Most Efficient Way To Pull Data From Multiple Files

    Hi Greg,

    Thanks so much for the help worked brilliantly.

    just one question why do you use:

    vbNullString instead of ""

    Thanks
    Christian

  4. #4
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Most Efficient Way To Pull Data From Multiple Files

    Hi again Christian,

    Many thanks for your feedback and also for the Reputation increase - much appreciated!

    You're welcome, I'm glad that I was able to help.

    Using vbNullString instead of "" is just a personal preference. In general I try to minimise the number of " characters in the body of my routines (unless it relates to something like the text to be displayed in a message or prompt) - instead I usually define text values (e.g. "B23:E30") as constants at the start of a routine. There's nothing sacred about this - I just find it to be a bit more convenient when checking my code.

    Best regards,

    Greg M

+ 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. How multiple files can pull data from Master file
    By prabhuduraraj09 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-06-2019, 08:50 PM
  2. Macro to Pull Data From Multiple Files
    By Jess709 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-23-2015, 02:39 PM
  3. Is there a more efficient way to import multiple XML files
    By anrichards22 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-10-2015, 12:50 AM
  4. VBA to pull data from multiple files
    By jasonleewkd in forum Excel General
    Replies: 1
    Last Post: 08-26-2012, 03:16 AM
  5. Macros to pull data from multiple files
    By danrub25 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-05-2011, 06:38 PM
  6. Code to pull data from multiple files?
    By WaveOfMutilation in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-17-2010, 07:25 PM
  7. [SOLVED] How do I pull data from multiple files and copy into one file
    By JT in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-03-2005, 03:06 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