Results 1 to 8 of 8
  1. #1
    Bronze Lounger
    Join Date
    Feb 2008
    Posts
    1,420
    Thanks
    124
    Thanked 5 Times in 5 Posts

    Macro Copy/Combine Data

    I need several workbooks ending in *.NewVehicles (Sheet also ending in *.Newvehicles) to be copied to the consolidated workbook sheet1, but excluding the totals from the various workbooks. I will set up a macro once copied to add the totals

    Your assistance will be most appreciated

    Regards

    Howard
    Attached Files Attached Files

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Macro Copy/Combine Data

    You don't provide us much details of what you want the code to do. Check out the code in the thread starting at <post:=714,177>post 714,177</post:> which should be adaptable (if I understand the basic gist of your request). If you have questions on adapting the code or need additional info, please provide additional details of what you want/need the code to do.

    Steve

  3. #3
    Bronze Lounger
    Join Date
    Feb 2008
    Posts
    1,420
    Thanks
    124
    Thanked 5 Times in 5 Posts

    Re: Macro Copy/Combine Data

    Hi Steve

    Thanks for the reply. I need the following to be done using VBA Code

    1) I need columns N2:T to be copied from each workbook in the folder my Documents ending in Newvehicles for eg Newton Newvehicles, East Newvihicles etc (sheet also ending in New Vehicles)except the totals which appears after the last row of data. The first workbook must copy the data from workbook Newton Newvehicles sheet New.NewVehicles from N1:T , the rest of the workbooks ending in Newvehicles must be copies from Sheet Newvehicles N2:T
    2) The above must me copied into Sheet1 into Workbook "Consolidated New Vehicles for eg if the first workbook Newton New Vehicles Sheet New.Newvehicles has been copied and the last row in Consolidfated New Vehicles is row 10, then the next workbook must be copied from row 11 onwards etc

    Your assistance will be most appreciated

    Howard

    2) I need column

  4. #4
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Macro Copy/Combine Data

    How does the attached do?

    Note: your example file has many modules in it (most with nothing in them) and the extra modules seem to make opening the files sluggish. You should delete the modules you are not using. I recommend that You should remove/delete the unused modules...

    Steve
    Attached Files Attached Files

  5. #5
    Bronze Lounger
    Join Date
    Feb 2008
    Posts
    1,420
    Thanks
    124
    Thanked 5 Times in 5 Posts

    Re: Macro Copy/Combine Data

    Hi Steve

    I tried to run your macro, but nothing happens i.e data not copied

    See attached file example
    Attached Files Attached Files

  6. #6
    Bronze Lounger
    Join Date
    Feb 2008
    Posts
    1,420
    Thanks
    124
    Thanked 5 Times in 5 Posts

    Re: Macro Copy/Combine Data

    Hi Steve

    I have also attached Consolidated Workbook "Consolidated.New vehicles" containing your code. Please test & correct

    Regards

    Howard
    Attached Files Attached Files

  7. #7
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Macro Copy/Combine Data

    When you stepped through the code, where did it fail?

    My guess is that you didn't set the last sPath string to the folder which contains your files. I tested it on a folder named "C:MyPath", but if you did not change this and you have no files ending in "newvehicles" in this folder (or the folder does not exist) then the code would never find any workbooks to open and work with...

    I did test the macro before posting and the problem seems to be in your setup vs what I presumed your setup was...
    Steve

  8. #8
    Bronze Lounger
    Join Date
    Feb 2008
    Posts
    1,420
    Thanks
    124
    Thanked 5 Times in 5 Posts

    Re: Macro Copy/Combine Data

    Hi Steve

    Thanks for the help

    I removed sPath = "C:MyPath" from the code and it now works perfectly

    Regards

    Howard

Posting Permissions

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