Results 1 to 6 of 6

Copy data from 3 separate workbooks into one master file VBA

Threaded View

  1. #1
    Forum Contributor
    Join Date
    02-13-2018
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    205

    Copy data from 3 separate workbooks into one master file VBA

    Hello,

    I am seeking help on a some VBA I wrote to copy selected range, within selected sheet for all workbooks within a file folder.

    Here is what I want to do:

    have the zmaster run a macro to bring in all date from the sheets labeled "Reach". I want columns A-V and then all the way down to the last row of data for each. The amount of data will change very month, so that is why I need to to the last row of data. Then paste all those results from the 3 active workbooks (FS Measures Jan 23, FS Measures Feb 23, FS Measures Mar 23) in the Master starting at A1 on "Sheet1". Here is the code I have so far. However, I get a return error 1004. I would like to be able to rename the workbooks being copied anything I want at any given time. I am not sure why the code is not reading the file names. Workbook is attached.

    Sub LoopThroughDirectory()
    
    Dim myfile As String
    Dim erow ' last row
    myfile = Dir("C:\suppliers-master\") 'location of file
    
    Do While Len(myfile) > 0
    
    If myfile = "zmaster.xlsm" Then
    Exit Sub
    End If
    
    Workbooks.Open (myfile)
    Worksheets("Reach").Activate
    Range("A1:V1").End(xlDown).Copy
    ActiveWorkbook.Close
    
    
    erow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
    
    ActiveSheet.Paste Destination:=Worksheets("Sheet1").Range(Cells(erow, 1), Cells(erow, 22))
    
    myfile = Dir
    
    Loop
    
    End Sub
    Rtn error.PNG

    file path.PNG
    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. Updating a workbooks own copy of data from a master file.
    By kadeo in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-10-2016, 06:48 AM
  2. Pulling Data from Multiple Workbooks into a Separate Master Workbook
    By awebster in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-10-2016, 01:09 PM
  3. Replies: 2
    Last Post: 09-18-2014, 05:42 AM
  4. Macro to transfer data from multiple workbooks into separate sheets of master file
    By salva7ore in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-20-2014, 08:18 PM
  5. I need to copy data from various workbooks into one master file, specific data
    By madhumith13 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-21-2013, 09:14 AM
  6. Exporting data from separate workbooks to master workbook
    By therock1986 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-22-2010, 11:43 AM
  7. Update master workbook data from separate workbooks
    By Deamo in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-25-2010, 02:32 AM

Tags for this Thread

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