Results 1 to 5 of 5

Copy multiple cells from several work books to one workbook

Threaded View

Blur1973 Copy multiple cells from... 01-20-2008, 05:08 PM
davesexcel See if this thread can get... 01-20-2008, 05:13 PM
Blur1973 Almost there? 01-20-2008, 06:37 PM
davesexcel Workbooks("Income Statement... 01-20-2008, 06:48 PM
Blur1973 It is working 01-20-2008, 08:20 PM
  1. #3
    Registered User
    Join Date
    01-20-2008
    Posts
    3

    Smile Almost there?

    Great link I am almost there.....it runs fine but the final result is it only posts the data from the final invoice. I tested this macro with five invoices (142, 143, 144, 145, 146) Only the data from the 146 invoice workbook went onto the "Income Statement Sheet.xls".....something I did to kill the loop?


    Here is the VBA:

    Sub GetInvoiceData()
        Dim i As Integer
        Dim wbResults As Workbook
        Dim wbCodeBook As Workbook
        Range("A2:F400").ClearContents 'delete sheet to suite
    
        Application.ScreenUpdating = False
        Application.DisplayAlerts = False
        Application.EnableEvents = False
        On Error Resume Next
    
        Set wbCodeBook = ThisWorkbook
    
        With Application.FileSearch
            .NewSearch
            'Change path to suit
            .LookIn = "C:\Documents and Settings\Lyds\Desktop\Test"
            .FileType = msoFileTypeExcelWorkbooks
    
            If .Execute > 0 Then    'Workbooks in folder
                For i = 1 To .FoundFiles.Count    'Loop through all
                    'Open Workbook x and Set a Workbook variable to it
                    Set wbResults = Workbooks.Open(.FoundFiles(i))
    
    
                    Workbooks("Income Statement Sheet").Sheets("Master Sheet").Range("b2").End(xlUp).Offset(1, 0) = Range("A16")
    
                    Workbooks("Income Statement Sheet").Sheets("Master Sheet").Range("c2").End(xlUp).Offset(1, 0) = Range("G15")
    
                    Workbooks("Income Statement Sheet").Sheets("Master Sheet").Range("d2").End(xlUp).Offset(1, 0) = Range("H36")
    
                    Workbooks("Income Statement Sheet").Sheets("Master Sheet").Range("e2").End(xlUp).Offset(1, 0) = Range("H37")
                    
                    Workbooks("Income Statement Sheet").Sheets("Master Sheet").Range("f2").End(xlUp).Offset(1, 0) = Range("H38")
    
                    
                    'Sheets("Invoice").Range ("A16,G15,H36,H37,H38")
                    ActiveWorkbook.Close savechanges:=False
                Next i
            End If
        End With
    
        On Error GoTo 0
        Application.ScreenUpdating = True
        Application.DisplayAlerts = True
        Application.EnableEvents = True
    End Sub

    Thanks Dave....This websiet is Great!
    Last edited by VBA Noob; 01-20-2008 at 06:44 PM.

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