Results 1 to 3 of 3

Extracting data from different workbooks combine into one VBA

Threaded View

  1. #1
    Registered User
    Join Date
    02-08-2019
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2

    Extracting data from different workbooks combine into one VBA

    Hi Friends,

    I am a beginner user of VBA. I want to take average of specific columns in different workbooks (average values are at the last row) and put them in another workbook. I could not do the loop it did not work. I need to take average of 3rd 4th and 5th columns. And put the results in another workbook. For the data taken from each workbook the results rows offsets one below. And 3rd column s result will be in 1st column in the mainworkbook where I want to keep the results. Every time I changed the numbers in the code and I could take data. Could you please help me about the code below. THANKS


    Sub LoopThroughDirectory()
    Dim MyFile As String
    Dim erow
    MyFile = Dir("...")
    
    Do While Len(MyFile) > 0
    If MyFile = "results1.xlsm" Then
    Exit Sub
    End If
    
    Workbooks.Open (MyFile)
    
    Worksheets("Time series").Cells(1, 5).End(xlDown).Offset(1, 0).Value = Application.WorksheetFunction.Average(Worksheets("Time series").Columns(5))
    Worksheets("Time series").Cells(1, 5).End(xlDown).Copy
    Application.DisplayAlerts = False
    ActiveWorkbook.Close
    
    erow = Sheet1.Cells(Rows.Count, 3).End(xlUp).Offset(1, 0).Row
    ActiveSheet.Paste Destination:=Worksheets("sheet1").Range(Cells(erow, 3), Cells(erow, 3))
    MyFile = Dir
    Loop
    Application.DisplayAlerts = True
    
    End Sub
    Last edited by alicans84; 02-08-2019 at 12:20 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Extracting data from multiple workbooks into one
    By henke_a_ in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-21-2018, 07:37 AM
  2. Extracting data from closed workbooks
    By Zagra147 in forum Excel General
    Replies: 3
    Last Post: 08-10-2018, 06:33 PM
  3. PC becomes unresponsive when extracting data from MANY workbooks
    By bongaan in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-05-2013, 07:39 AM
  4. combine workbooks and data
    By jmatthews in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-10-2012, 03:46 PM
  5. Extracting Data from specific Cells in many different workbooks into one row
    By Ebun in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-02-2011, 06:55 AM
  6. Extracting Data from Changing Workbooks
    By chiggachoo in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 04-20-2010, 11:17 PM
  7. Combine Data from different workbooks
    By zplugger in forum Excel Programming / VBA / Macros
    Replies: 33
    Last Post: 04-22-2009, 03:17 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