+ Reply to Thread
Results 1 to 9 of 9

Combine data from multiple files into a master file using VBA

  1. #1
    Registered User
    Join Date
    12-28-2014
    Location
    Birmingham, England
    MS-Off Ver
    2010
    Posts
    54

    Combine data from multiple files into a master file using VBA

    Hello

    In continuation to my previous posts on this subject, I have set up a master file which combines data from 6 different files. My query has 2 parts.

    Query 1
    I am currently trying to combine the data in the Spot Quotes Tab from each individual user file into the "Combine Data" Tab of the master file (South UK Spot quotes). The code works fine except for 2 of the user files - Price Desk Quotesheet M and Price Desk Quotesheet Mi. In the case of these files, it is not determining the last row in the file correctly (I am not sure if this is because the first data row Row 12 / Column D is blank in these files) and therefore copying the header. I did try to put in a code if there is no data but not sure if I have got it right...Need some ideas on how to resolve this.

    Query 2
    The second stage of this project is to copy the data from each tab (Spot Quotes, Network Quotes and Sales Proposal) in each user file to the Combined Data, Combined Data Network and Combined Data Sales Prop tabs respectively in the Master file. My idea was to replicate the code I have for the Spot Quotes data for each of the other tabs, but is that the most efficient way of doing it?

    Hope to have some help on this.

    Thank you.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Combine data from multiple files into a master file using VBA

    1 Headers in Row 11 like in your file
    2 Loop for Columns D to Y to find the last Row

    maybe this give you idee for query 2

    Please Login or Register  to view this content.
    Cheers
    Leo

  3. #3
    Registered User
    Join Date
    12-28-2014
    Location
    Birmingham, England
    MS-Off Ver
    2010
    Posts
    54

    Re: Combine data from multiple files into a master file using VBA

    [QUOTE=LeoTaxi;4497908]1 Headers in Row 11 like in your file
    2 Loop for Columns D to Y to find the last Row

    Hi Leo

    Thanks for responding.

    I checked all files and the headers are in Row 11 in each file. Im not sure I understand what you mean? I am new to vba so so appreciate if you could explain the above.

    Thanks!

  4. #4
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Combine data from multiple files into a master file using VBA

    to understand you have to read your own code
    the part where this comment is
    we dont want delete the headers
    Did you test the Code ?

    Cheers
    Leo

  5. #5
    Registered User
    Join Date
    12-28-2014
    Location
    Birmingham, England
    MS-Off Ver
    2010
    Posts
    54

    Re: Combine data from multiple files into a master file using VBA

    the code was working fine until I added the 2 sheets - Prices Desk Quotesheet M and Prices Desk Quotesheet Mi.

    Yes the code does say "don't want to delete the headers - and I don't want to delete the headers! but I do not want the code to copy the headers out from each file either....hence the query. The code is only copying the headers for these 2 files so I guess for some reason it is not able to determine which row is the header row..

  6. #6
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Combine data from multiple files into a master file using VBA

    Code i provided does not copy headers, only data

    cheers
    Leo

  7. #7
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Combine data from multiple files into a master file using VBA

    If the result from code i provided is different from desired result, post a file with desired result.


    Cheers
    Leo

  8. #8
    Registered User
    Join Date
    12-28-2014
    Location
    Birmingham, England
    MS-Off Ver
    2010
    Posts
    54

    Re: Combine data from multiple files into a master file using VBA

    Hi Leo

    Sorry for the delay in getting back to you... I tried the code....I am getting an error at this stage... "Run time error 1004: Application defined or object defined error

    .Range(Cells(12, "D"), Cells(RowNum, "Y")).Copy sh.Range("D" & lr2 + 1)

    What does this error refer to?

    Thank you

  9. #9
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Combine data from multiple files into a master file using VBA

    If the result from code i provided is different from desired result, post a file with desired result.
    can nothing do without file

    cheers
    Leo

+ 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: 2
    Last Post: 06-17-2014, 11:16 AM
  2. Vba macro help to pull data from multiple closed files to master file !!!
    By johnodys in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-08-2013, 07:44 AM
  3. Consolidate Data from Multiple Files (Different File Names) into a Master File
    By dspraveen_23 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-08-2012, 12:59 PM
  4. Combine multiple Ecxel files in one master file with VB
    By jelena1290 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 11-10-2012, 12:36 AM
  5. Copying data from multiple files in a folder to a master file
    By kjshep in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-22-2012, 12:31 PM
  6. Replies: 8
    Last Post: 06-27-2012, 03:09 PM
  7. Need to combine tons of files to a master file for pivot reporting
    By betsymc in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 02-09-2012, 03:05 AM

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