Results 1 to 3 of 3

Thread: Copy Data From Multiple Workbooks To A Master Workbook

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member
    Join Date
    May 2013
    Posts
    2
    Rep Power
    0

    Copy Data From Multiple Workbooks To A Master Workbook

    Hi all

    I have an excel (2010) workbook which contains 1 worksheet called MASTER. This sheet has the headers starting in A1 through E1:

    Date
    Company Name
    Contact
    TorV
    Details

    I want a VBA script that will run from the MASTER worksheet and allow me to select multiple workbooks in a folder and copy the data (from ROW 22) until LAST ROW and add it to the worksheet called MASTER.

    I already have a VBA script (shown below so that other users can use) which allows me to select multiple workbooks in a folder and pull out individual cells data but I need to change the script to pull out ROWS data as per the paragraph above.

    I have just got back off holiday and my mind is blank as to how to change the script

    Many Thanks


    Craig:

    Code:
    Sub BulkImport()
       Dim InFileNames As Variant
       Dim OutFileName As String
       Dim fCtr As Long
       Dim tempWkbk As Workbook
       Dim consWks As Worksheet
       Dim destCell As Range
       Dim myRow As Long
       Dim total As Long
       Dim LastRow As Long
       Set consWks = ActiveWorkbook.Sheets(1)
       LastRow = consWks.Range("A65536").End(xlUp).Row
       InFileNames = Application.GetOpenFilename _
       (FileFilter:="Excel Files, *.xl*", MultiSelect:=True)
       Application.ScreenUpdating = False
       If IsArray(InFileNames) Then
          For fCtr = LBound(InFileNames) To UBound(InFileNames)
             Set tempWkbk = Workbooks.Open(Filename:=InFileNames(fCtr))
             consWks.Range("A" & fCtr + LastRow).Value = tempWkbk.Worksheets(1).Range("A22").Value
             consWks.Range("B" & fCtr + LastRow).Value = tempWkbk.Worksheets(1).Range("B22").Value
             consWks.Range("C" & fCtr + LastRow).Value = tempWkbk.Worksheets(1).Range("C22").Value
             consWks.Range("D" & fCtr + LastRow).Value = tempWkbk.Worksheets(1).Range("D22").Value
             consWks.Range("E" & fCtr + LastRow).Value = tempWkbk.Worksheets(1).Range("E22").Value
           ActiveWorkbook.Close
          Next fCtr
       Else
          MsgBox "No file selected"
       End If
       With Application
          .StatusBar = False
          .ScreenUpdating = True
       End With
    End Sub
    Last edited by Excel Fox; 05-28-2013 at 04:31 PM. Reason: Code Tags Added

Similar Threads

  1. Replies: 1
    Last Post: 06-07-2013, 10:32 AM
  2. Replies: 1
    Last Post: 05-09-2013, 08:56 AM
  3. Consolidate multiple workbooks from a folder into one master file VBA
    By Admin in forum Excel and VBA Tips and Tricks
    Replies: 4
    Last Post: 02-26-2013, 09:00 PM
  4. Replies: 2
    Last Post: 11-08-2012, 01:15 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •