+ Reply to Thread
Results 1 to 6 of 6

Macros script that loads data from other excel documents

  1. #1
    Registered User
    Join Date
    03-13-2014
    Location
    Latvia
    MS-Off Ver
    Excel 2007
    Posts
    12

    Macros script that loads data from other excel documents

    Hello,
    i have script that helps me to get all data from other excel documents (same kind) with different information and from many sheets in one place if there is something written in G column. the only bad thing is that i want to figure out why my date cells are being copied as general numbers and doesn't keep the date formatting? i kinda have the formatting for those column cells but it doesn't work. maybe there is something you could help me to fix? the date formatting is in G, H, I and some other fields, not all columns are defined here to have date formatting set.
    i would be really grateful for your input.
    here is the script:

    Please Login or Register  to view this content.

  2. #2
    Registered User
    Join Date
    03-13-2014
    Location
    Latvia
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Macros script that loads data from other excel documents

    anyone with a thought maybe?

  3. #3
    Valued Forum Contributor
    Join Date
    11-26-2012
    Location
    Sydney
    MS-Off Ver
    2010
    Posts
    419

    Re: Macros script that loads data from other excel documents

    Don't have a direct answer to your question, but hope this helps.

    There is no need to use copy / paste, and it should generally be avoided. Simply set the destination range equal to the source range. This is much faster, and should avoid your formatting issue. I won't gurantee that, however - dates and formatting in Excel can be very troublesome, especially when VBA is involved!

    E.g. The following code copies the first 100 rows and 10 columns from one workbook to another. You can repeat this in a loop for multiple files, incrementing r as needed.

    Please Login or Register  to view this content.



    Incidently, the following code is redundant:

    Please Login or Register  to view this content.
    can be replaced with

    Please Login or Register  to view this content.
    and it will do exactly the same thing.
    Last edited by mgs73; 04-23-2014 at 04:27 AM.

  4. #4
    Registered User
    Join Date
    03-13-2014
    Location
    Latvia
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Macros script that loads data from other excel documents

    Indeed it worked regarding copying date cells with correct formatting. now i will have to try to include also the statement that if there is something written in G cell then this row has to be copied.

  5. #5
    Registered User
    Join Date
    03-13-2014
    Location
    Latvia
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Macros script that loads data from other excel documents

    hmm, but the only thing is that i need to collect all data from different excel documents and their sheets and append all data into one worksheet from all others having the same name of columns to represent the data. as well from this i am going to use pivot table to sort information as needed. to what it does now is just open the excel document where all my data is..which is not what i want it to do. i need to fully import data from one excel to another.

  6. #6
    Valued Forum Contributor
    Join Date
    11-26-2012
    Location
    Sydney
    MS-Off Ver
    2010
    Posts
    419

    Re: Macros script that loads data from other excel documents

    I have corrected a mistake I made before, as I neglected to use the r variable I mentioned.

    If you want to get data from several sheets in another spreadsheet, and put them onto sheet in your active spreadsheet, try something like this:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    03-13-2014
    Location
    Latvia
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Macros script that loads data from other excel documents

    how can i copy only that much rows as there are currently in the worksheet as there are people adding more and more data in this sheet + append data right after those first sheet filled in cells.

+ 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. Replies: 5
    Last Post: 01-20-2014, 06:25 AM
  2. convert all 97-2003 excel documents to macro enabled documents on server
    By viperisback in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-23-2013, 09:06 AM
  3. Replies: 1
    Last Post: 04-28-2006, 04:40 PM
  4. [SOLVED] Calling excel-macros from script?
    By grz01 in forum Excel General
    Replies: 4
    Last Post: 05-04-2005, 07:06 PM
  5. Calling excel-macros from script?
    By grz01 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-04-2005, 07:06 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