+ Reply to Thread
Results 1 to 6 of 6

Extract Data From Multiple Excel Files -> One File

  1. #1
    Registered User
    Join Date
    05-15-2013
    Location
    Nederland
    MS-Off Ver
    Excel 2003
    Posts
    4

    Extract Data From Multiple Excel Files -> One File

    Hi,

    Im trying to get some data from multiple excel files to one file using the following code.
    The macro now copies information from a excel file (G10:T10) and pasts it in a cell than opens the next excel file, copies the information and pastes it in the same cell.
    My problem is that i want the copied data not to be overwritten but to be pasted under each other, so it will result in a list of information.
    I hope someone could help me with this!

    Sub ConsolidateData()
    Dim FileSystem As Object, myFolder As Object
    Dim myFiles As Object, myFile As Object
    Dim wkb, Col As Integer, result
    Set FileSystem = CreateObject("Scripting.FileSystemObject")
    Set myFolder = FileSystem.getfolder(CurDir)
    Set myFiles = myFolder.Files
    For Each myFile In myFiles
    Col = ThisWorkbook.Sheets(1).UsedRange.Columns.Count
    Workbooks.Open (myFile)
    ActiveWorkbook.Sheets(1).Range("G10:T10").Copy
    ActiveSheet.Paste Destination:=ThisWorkbook.Sheets(1).Cells(1, Col) '= ActiveWorkbook.Sheets(1).Range("G10:T10")
    Workbooks.Open(myFile).Close False
    Next myFile

    End Sub

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

    Re: Extract Data From Multiple Excel Files -> One File

    Here is a similar request from a couple of days ago.

    http://www.excelforum.com/excel-prog...worksheet.html
    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-15-2013
    Location
    Nederland
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Extract Data From Multiple Excel Files -> One File

    I see Thanks.
    Problem is that im to much of noob to understand the code.
    I thought that the bold part: ActiveSheet.Paste Destination:=ThisWorkbook.Sheets(1).Cells(1, Col)
    Could maybe be replaced with some simple code that tells the macro to paste the date under each other.

    Is this possible? because the rest of the code works fine!

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

    Re: Extract Data From Multiple Excel Files -> One File

    I am in the middle of a project right now, but if you look at my code and the explanations for determining the last cell (last row) in a column and apply that concept to your project. My code is explained fully with comments so you should be able to follow it.

    Alan

  5. #5
    Registered User
    Join Date
    05-15-2013
    Location
    Nederland
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Extract Data From Multiple Excel Files -> One File

    Ill Try! Many THanks!

  6. #6
    Registered User
    Join Date
    05-15-2013
    Location
    Nederland
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Extract Data From Multiple Excel Files -> One File

    I havnt been able to get working.
    Can someone please help me?

+ 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