Results 1 to 3 of 3

Copying column from 200+ workbooks to a master file (already attempted!)

Threaded View

  1. #1
    Registered User
    Join Date
    08-16-2012
    Location
    San Francisco, CA
    MS-Off Ver
    Excel 2013
    Posts
    9

    Copying column from 200+ workbooks to a master file (already attempted!)

    Hi,

    I am new to VBA and looking to be able to automatically generate a master dataset by automatically copying a certain column from ~200 raw data workbooks. These will be accumulating over several weeks. For example, I may have 10 files in week 1, then 20, then 30, etc. I want to be able to drag and drop a new set of Excel data files into a folder with all existing ones, click a button, and have my master Excel updated with all data available to date.

    I have attempted this with 3 workbooks and one master file. If it worked correctly, the data would appear in columns C-E in the master file. However, my code is not working. I am fairly certain at least one of the problems is the way I defined "ecolumn". I also know that my code may not work if any data file is alphabetically after "Master", so if anyone can suggest a fix to that as well, that would be helpful.

    Additionally, I would also eventually like to transpose all of the data so that each data source is a row, if anyone also would be able to help with that.

    I have pasted the module below, and attached the sample files. Could anyone help me with this? Thanks!

    Sub LoopThroughDirectory()
    Dim MyFile As String
    Dim ecolumn
    MyFile = Dir("C:\Test")
    Do While Len(MyFile) > 0
    If MyFile = "Master.xlsm" Then
    Exit Sub
    End If
    Workbooks.Open (MyFile)
    Range("C1:C12").Copy
    ActiveWorkbook.Close
    ecolumn = Master.Cells(1, Columns.Count).End(x1ToLeft).Column + 1
    ActiveSheet.Paste Destination:=Worksheets("Master").Range(Cells(1, ecolumn), Cells(12, ecolumn))
    MyFile = Dir
    Loop
    
    End Sub
    Attached Files Attached Files

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: 09-18-2014, 05:42 AM
  2. Macro- Copying Multiple Workbooks into Master
    By eric.cappelli in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-14-2009, 08:02 AM
  3. Macro- Copying Multiple Workbooks into Master
    By eric.cappelli in forum Excel General
    Replies: 1
    Last Post: 05-13-2009, 07:37 AM
  4. Macro- Copying Multiple Workbooks into Master
    By eric.cappelli in forum Excel General
    Replies: 0
    Last Post: 05-11-2009, 05:32 AM
  5. Macro-copying multiple workbooks into master
    By eric.cappelli in forum Excel General
    Replies: 0
    Last Post: 05-08-2009, 08:12 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