Results 1 to 7 of 7

Macro to read multiple excel workshops, copy selected cells & consolidate work in workbook

Threaded View

  1. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,652

    Re: Macro to read multiple excel workshops, copy selected cells & consolidate work in work

    Try something like this.

    ThisWorkbook refers to the workbook that contains the macro code. I assumed it was the same workbook you wanted to paste to.

    Change Sheet1 to the name of the destination sheet.

    Sub openandcopy()
        
        Dim Counter As Long, FileDir As String, FileName As String
        
        FileDir = "D:\Projects\Futureact\Q4 Responses\"    'directory containing all the workbooks
        FileName = Dir(FileDir & "*.xls")
        
        Application.ScreenUpdating = False
        Do While FileName <> ""
            With Workbooks.Open(FileName:=FileDir & FileName)
                .ActiveSheet.Range("B3:E3").MergeCells = False 'unmerge cells
                .ActiveSheet.Range("B3").Copy _
                    Destination:=ThisWorkbook.Sheets("Sheet1").Range("B" & Rows.Count).End(xlUp).Offset(1)
                    'Next empty row in column B
                .Close SaveChanges:=True
            End With
            Counter = Counter + 1
            FileName = Dir
        Loop
        Application.ScreenUpdating = True
        
        MsgBox Counter & " files copied", vbInformation, "Copy Complete"
        
    End Sub
    Last edited by AlphaFrog; 08-09-2013 at 02:42 AM.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. macro to copy cells to a new workbook doesn't work properly
    By dileva in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-12-2013, 10:55 AM
  2. [SOLVED] Macro to read the multiple csv files and consolidate into single excel
    By parthmittal2007 in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 01-03-2013, 03:40 AM
  3. Help! Macro to consolidate data from multiple workbook sheets!
    By Sainath Krishnan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-08-2012, 08:18 AM
  4. copy selected range from multiple workbooks into multiple worksheets in one workbook
    By novak100 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-13-2012, 05:52 AM
  5. Copy multiple cells from several work books to one workbook
    By Blur1973 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-20-2008, 08:20 PM

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