+ Reply to Thread
Results 1 to 12 of 12

Copying data from multiple workbooks into a blank one.

  1. #1
    Registered User
    Join Date
    05-02-2016
    Location
    Bucharest,Romania
    MS-Off Ver
    2007
    Posts
    5

    Copying data from multiple workbooks into a blank one.

    Hello.I have a big problem ( for me ) and maybe a small one for you.I need to tell you that my VBA & Excel knowledge is almost 0 . So here's my problem: every week i receive like 100-150 excel files with a lot of data and i need to make a new one which should contain only a couple of data from each one. For example,i receive information for evey employee and i need to provide,let's say,only the name,id and location.I searched on google about this and i found some things but i have big problems trying to modify the code so it can work for my case. I am trying to understand the logic behind the VBA code ( i have some experience with c++ ) but i have some problems.

    Can anybody please help me ? Or at least explain to me how i should do that thing ? Thanks in advance.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,888

    Re: Copying data from multiple workbooks into a blank one.

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window (or use the paperclip icon).
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    05-02-2016
    Location
    Bucharest,Romania
    MS-Off Ver
    2007
    Posts
    5

    Re: Copying data from multiple workbooks into a blank one.

    So, i have a lot of workbooks like the "workbook" one with different data but the data that i need to collect is stored in the same row & colums.In the end, i have to make a new worksheet that stores the data like the "final" one.Cod site is found at : D5->E5,Nume site :I5->M5,Contractor:K8->O8 and Data vizitei:K10->L10.
    Attached Files Attached Files

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,888

    Re: Copying data from multiple workbooks into a blank one.

    Here is some code that has been modified to meet your needs.
    VBA typically does not like merged cells. You may have to unmerge the target cells in order for the code to work. Test this on some sample workbooks first.

    Please Login or Register  to view this content.
    Last edited by alansidman; 05-02-2016 at 11:41 AM.

  5. #5
    Registered User
    Join Date
    05-02-2016
    Location
    Bucharest,Romania
    MS-Off Ver
    2007
    Posts
    5

    Re: Copying data from multiple workbooks into a blank one.

    I tried to run the code but i have the following error : Object doesn't support this property or method.

  6. #6
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,888

    Re: Copying data from multiple workbooks into a blank one.

    When you get the error message, click on debug and tell us what line of code is highlighted.

  7. #7
    Banned User!
    Join Date
    10-29-2012
    Location
    Europe
    MS-Off Ver
    2013, 2016
    Posts
    318

    Re: Copying data from multiple workbooks into a blank one.

    alansidman,

    When running code, the error occurred to me Object doesn't support this property or method. and has been highlighted, this row of code:

    Please Login or Register  to view this content.

  8. #8
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,888

    Re: Copying data from multiple workbooks into a blank one.

    change the code to include a sheet name. My bad as I did this as air code and forgot to add the sheets

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    05-02-2016
    Location
    Bucharest,Romania
    MS-Off Ver
    2007
    Posts
    5

    Re: Copying data from multiple workbooks into a blank one.

    Now i have this error : Method open of object 'Workbooks' failed at this line: Set wb = Workbooks.Open(Filename:=myPath & myFile).

    Anyway,can you please help me to understand the logic behind this piece of code ?

    lr = wbx.Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row
    wb.Worksheets(1).Range("D5").Copy wbx.Sheets("Sheet1").Range("A" & lr + 1)
    wb.Worksheets(1).Range("I5").Copy wbx.Sheets("Sheet1").Range("C" & lr + 1)
    wb.Worksheets(1).Range("K8").Copy.wbx.Sheets("Sheet1").Range ("E" & lr + 1)
    wb.Worksheets(1).Range("K10").Copy wbx.Sheets("Sheet1").Range("H" & lr + 1)

    How does the program know how many columns it should copy? For example D5.It starts copying from D5 and when does it know when to stop?

  10. #10
    Banned User!
    Join Date
    10-29-2012
    Location
    Europe
    MS-Off Ver
    2013, 2016
    Posts
    318

    Re: Copying data from multiple workbooks into a blank one.

    @yoBogdan

    Delete point between Copy and VBX of this line and put a space
    Please Login or Register  to view this content.
    That piece of code do this:
    copy that is found in cell D5 of each sheet 1 of all files found in the folder specified in column A of sheet 1 of the file from which the code runs.
    Just copy that is found in cell I5 to the column C
    Just copy that is found in cell K8 to the column E
    Just copy that is found in cell K10 to the column H
    Last edited by Indi_Ra; 05-04-2016 at 09:57 AM.

  11. #11
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,888

    Re: Copying data from multiple workbooks into a blank one.

    @Indi_Ra

    Thanks for pointing out the typo and explaining the code.

  12. #12
    Registered User
    Join Date
    05-02-2016
    Location
    Bucharest,Romania
    MS-Off Ver
    2007
    Posts
    5

    Re: Copying data from multiple workbooks into a blank one.

    Ok now it works perfectly ! Thank you so much <3

    Is there any chance of copying the data without borders,bold etc ? I mean only the text.

+ 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. Copying data from multiple workbooks having multiple sheets into one master worksheet
    By Navya Ahuja in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-15-2014, 09:42 AM
  2. [SOLVED] Copying data from multiple workbooks into one
    By seigna in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-07-2014, 05:57 AM
  3. Copying data from multiple workbooks to 1 master workbook
    By chilli76 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-15-2014, 12:50 PM
  4. Copying of Data from Sheet3 from multiple workbooks
    By mvinay in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 12-18-2013, 02:27 PM
  5. Copying data from multiple workbooks and different columns
    By amartino44 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-24-2013, 01:51 PM
  6. copying cell data from multiple workbooks - Error 400
    By polishdrumsticks in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-20-2011, 10:24 AM
  7. [SOLVED] Help with Macro (copying data from multiple workbooks)
    By Tim Harding in forum Excel General
    Replies: 1
    Last Post: 02-05-2005, 07: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