+ Reply to Thread
Results 1 to 6 of 6

Extract data from closed workbooks and copy into new workbook

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    08-04-2004
    Location
    Amsterdam
    MS-Off Ver
    2016
    Posts
    186

    Extract data from closed workbooks and copy into new workbook

    First I will explain my problem.
    I have directories named 2008,2009,2010,2011,2012 and 2013.
    Within all directories are 2 large files (about 150mb to 220mb each) called Jumps and Flat. Each file has same number of columns with identical headings but varying number of rows
    Each has 2 sheets (the data sheet and a blank sheet). Data sheet has same name as workbook.

    I need to extract data based on values on one column only(always column m which is headed "Name").
    In sheet 2 I have a named range (A1:A40) which I enter the values I need to search for. This can be any amount of different text values from 2-40. Each value can appear multiple times (or not at all) in the lookup workbooks or only appear in some workbooks. I need to extract the entire row where the lookup data appears in column M and paste into a new workbook. It will need to be done in order so 2008-2013.

    Currently I open each book, enter the data in the named range area in sheet 2 and run a macro which filters the data sheet.
    It is ok but time consuming to open each file as it takes a while due to the huge size and if I have all files open then it becomes hard to manage.

    I need to
    1 have a master sheet into which I enter the values to search for.
    2 I choose whether to look in "Jumps" workbooks or "Flat" workbooks.
    2 The macro then goes to each workbook (Flat or Jumps for each directory) and extracts all rows where the data appears and pastes this into a 2nd sheet in my master. this will already have the headers. I don't really want to have to open each file.

    The macro I currently have is:
    Dim v As Variant
    Dim varCellContent As Range
    Dim ws As String
    
    On Error Resume Next
        Set varCellContent = Application.InputBox(Prompt:="Choose a sheet by clicking on any cell in it.", Type:=8)
        On Error GoTo 0
    
        If Not varCellContent Is Nothing Then
            ws = varCellContent.Parent.Name
                    Worksheets(ws).Activate
                    End If
     If ActiveSheet.FilterMode Then
        ActiveSheet.ShowAllData
      End If
    v = Application.Transpose(Range("MyList"))
        Worksheets(ws).Range("$A$1:$HO$50000").AutoFilter Field:=13, Criteria1:=v, Operator:=xlFilterValues
            
    End Sub

    Many many thanks to any help you can give
    I have Excel 2010
    Last edited by philaugust2004; 04-14-2013 at 12:17 PM. Reason: to put code tags in post

  2. #2
    Forum Contributor
    Join Date
    08-04-2004
    Location
    Amsterdam
    MS-Off Ver
    2016
    Posts
    186

    Re: Extract data from closed workbooks and copy into new workbook

    Gentle bump in case it was missed over the weekend

  3. #3
    Valued Forum Contributor Saarang84's Avatar
    Join Date
    02-19-2009
    Location
    Chennai, India
    MS-Off Ver
    XL 2003 to 2010
    Posts
    812

    Re: Extract data from closed workbooks and copy into new workbook

    Hi Phil,

    Try using the code available in the below links :

    Read information from a closed workbook
    Copy data from multiple workbooks


    Sarang

  4. #4
    Forum Contributor
    Join Date
    08-04-2004
    Location
    Amsterdam
    MS-Off Ver
    2016
    Posts
    186

    Re: Extract data from closed workbooks and copy into new workbook

    Thankyou.
    As an aside, is it possible to run an autofilter macro on a closed workbook?

  5. #5
    Valued Forum Contributor Saarang84's Avatar
    Join Date
    02-19-2009
    Location
    Chennai, India
    MS-Off Ver
    XL 2003 to 2010
    Posts
    812

    Re: Extract data from closed workbooks and copy into new workbook

    Hi Phil,

    As far as i know, it may not be possible to run an autofilter macro on a closed workbook. Maybe you can execute a macro code and open the workbook, apply necessary filters, extract data, remove the filters and then close it.


    Sarang

  6. #6
    Forum Contributor
    Join Date
    08-04-2004
    Location
    Amsterdam
    MS-Off Ver
    2016
    Posts
    186

    Re: Extract data from closed workbooks and copy into new workbook

    Hi Saarang

    I think that's what I have to do. I wanted to avoid it as they are huge files and take 30 seconds or so to open but I guess I can just run a macro and then go make a cup of tea!

+ Reply to Thread

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