+ Reply to Thread
Results 1 to 20 of 20

Copying data from Multiple spreadsheet to single spreadsheet

  1. #1
    Registered User
    Join Date
    05-08-2013
    Location
    In your gf's house
    MS-Off Ver
    Excel 2010
    Posts
    16

    Copying data from Multiple spreadsheet to single spreadsheet

    As the title suggest, I am trying to copy data from Multiple spreadsheet to single spreadsheet. There will be around 200-300 sheets. I did a lot of googling and found the following macro to be best.


    But the issue is I have some sheets, where first column is blank for all the records.

    For example I have 3 sheets like these.

    1 AAA
    2 BBB
    3 CCC
    4 DDD

    5 EEE
    FFF
    GGG
    HHH

    9 III
    10 JJJ


    When I execute the macro it is creating a final sheet like this.

    1 AAA
    2 BBB
    3 CCC
    4 DDD
    5 EEE
    9 III
    10 JJJ

    It is not copying the FFF,GGG and HHH rows. From further analysis I found that, when the macro is looking for the last cell to start pasting data for the next spreadsheet, It pointing to
    FFF

    Thus it is overwriting F,G and H records.

    How to overcome this issue?
    Last edited by Cool\m/; 05-09-2013 at 07:43 AM. Reason: Removed code

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copying data from Multiple spreadsheet to single spreadsheet

    Please attach your sample. This easily can be rectified, but we need to see the format of your data. Go to advance, then attachment.

  3. #3
    Registered User
    Join Date
    05-08-2013
    Location
    In your gf's house
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: Copying data from Multiple spreadsheet to single spreadsheet

    Here is a sample file I created. The data in sheet3 are getting overwritten.
    Last edited by Cool\m/; 05-09-2013 at 06:07 AM.

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copying data from Multiple spreadsheet to single spreadsheet

    There is not code on the attached. Is this right?

  5. #5
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Copying data from Multiple spreadsheet to single spreadsheet

    Hi, Cool\m/,

    maybe change the check for the last entry from Column A to Column B (assuming Columns A and B from the part of spreadsheet offered, or the Column which has consistent data in all rows)?

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  6. #6
    Registered User
    Join Date
    05-08-2013
    Location
    In your gf's house
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: Copying data from Multiple spreadsheet to single spreadsheet

    My bad, forgot to attach the macro code . Edited my first post with the code.

    Here is the xls with code.
    Last edited by Cool\m/; 05-09-2013 at 07:44 AM.

  7. #7
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copying data from Multiple spreadsheet to single spreadsheet

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    05-08-2013
    Location
    In your gf's house
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: Copying data from Multiple spreadsheet to single spreadsheet

    Quote Originally Posted by HaHoBe View Post
    Hi, Cool\m/,

    maybe change the check for the last entry from Column A to Column B (assuming Columns A and B from the part of spreadsheet offered, or the Column which has consistent data in all rows)?

    Ciao,
    Holger
    Thats where I am stuck.

    This is the line which is culprit.
    Range("A65536").End(xlUp).Offset(1, 0).Select

    I am big noob with vb and macro.

  9. #9
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copying data from Multiple spreadsheet to single spreadsheet

    The code you have attached has lots of select. Please use my code and let me know if you have any issue.

  10. #10
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Copying data from Multiple spreadsheet to single spreadsheet

    Hi, Cool\m/,

    instead of using Column A
    Please Login or Register  to view this content.
    use Column B like
    Please Login or Register  to view this content.
    although I know you would not need to select a cell for any code to work.

    Ciao,
    Holger

  11. #11
    Registered User
    Join Date
    05-08-2013
    Location
    In your gf's house
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: Copying data from Multiple spreadsheet to single spreadsheet

    Quote Originally Posted by AB33 View Post
    The code you have attached has lots of select. Please use my code and let me know if you have any issue.
    No data is populated in Master sheet.

  12. #12
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copying data from Multiple spreadsheet to single spreadsheet

    Put a header in Master List sheet in row1 and code works perfectly.

  13. #13
    Registered User
    Join Date
    05-08-2013
    Location
    In your gf's house
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: Copying data from Multiple spreadsheet to single spreadsheet

    It worked, but I want the data as it is, it will contain the filenames and column names for all the sheets. i.e , in master sheet,
    Column1 Column2 Column3

    will appear thrice for 3 sheets.


    Also the number of records varries, in some sheets it is more than 50. And thanks for your quick response.
    Last edited by Cool\m/; 05-09-2013 at 06:11 AM.

  14. #14
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copying data from Multiple spreadsheet to single spreadsheet

    Filename: Sheet1.xls

    Column1 Column2 Column3

    Do you mean all data need to be copied in to master sheet, even the columns? I can understand why you want to copy the file name and sheets, but not the columns. So, basically, you want to copy everything in every sheet.

  15. #15
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copying data from Multiple spreadsheet to single spreadsheet

    Please Login or Register  to view this content.
    Last edited by AB33; 05-09-2013 at 06:45 AM.

  16. #16
    Registered User
    Join Date
    05-08-2013
    Location
    In your gf's house
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: Copying data from Multiple spreadsheet to single spreadsheet

    Well column1,2,3 are not required, but it is allright if those exist, but the filenames are mandatory. So I did some modification to your code to include them as well. Please check it once.

    Please Login or Register  to view this content.
    Added a line to include formatting also, as some cells are merged.
    Removed these two lines
    ms.Range("A2:A" & Rows.Count - 1).NumberFormat = "dd/mm/yyyy"
    ms.Range("C2:C" & Rows.Count - 1).NumberFormat = "#,###0.00"
    Data may not be date as well in some sheets

  17. #17
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copying data from Multiple spreadsheet to single spreadsheet

    See amended post#15

  18. #18
    Registered User
    Join Date
    05-08-2013
    Location
    In your gf's house
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: Copying data from Multiple spreadsheet to single spreadsheet

    Wow.. thats working exactly what I want. Thanks a lot,

    Just a little change i did, as I want to copy the formatting also. added the
    ms.Range("A" & NR).PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False

    ms.Range("A" & NR).PasteSpecial Paste:=xlFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    Will it break anything?

    Anyway lot of thanks, I was stucked here from yesterday.

  19. #19
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copying data from Multiple spreadsheet to single spreadsheet

    Will it break anything?
    No, but it will slow down the code as the code has to copy all formats.


    Could you please now close (Mark) this thread as solved? Go in to the top right-hand side of this page, choose "Thread Tools" from the menu, then select "solved" from the drop down menu.

  20. #20
    Registered User
    Join Date
    05-08-2013
    Location
    In your gf's house
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: Copying data from Multiple spreadsheet to single spreadsheet

    Done Sir.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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