+ Reply to Thread
Results 1 to 6 of 6

Extracting Worksheet from multiple files + consolidated them...

Hybrid View

  1. #1
    RCRod83
    Guest

    Extracting Worksheet from multiple files + consolidated them...

    Hello,

    What is the best way to accomplish the following?

    1. Extract Sheet7 from multiple excel files (the files are budget templates, so they are exactly the same). The sheet 7 has formulas, so I would need to extract the values.

    2. Load Sheet 7 into one excel sheet (Sheet 7 tab name is different in each excel file, but it is Sheet7).

    3. Using the same template format, I would like to combine all the values across all the sheets into 1 worksheet. I.e. Take the value in "A7" from all the worksheets and sum it together into A7 on Sheet1.

    I hope this makes sense.

    Thanks!

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Extracting Worksheet from multiple files + consolidated them...

    'WORKBOOKS TO 1 SHEET STACKED
    Here's a macro for collecting data from all files in a specific folder.
    The parts of the code that need to be edited are colored to draw your attention.

    ===============

    The main customization will be in this section:
            'This is the section to customize, replace with your own action code as needed
                LR = Range("A" & Rows.Count).End(xlUp).Row  'Find last row
                Range("A1:A" & LR).EntireRow.Copy .Range("A" & NR)
                wbData.Close False                                'close file
                NR = .Range("A" & .Rows.Count).End(xlUp).Row + 1  'Next row
                Name fPath & fName As fPathDone & fName           'move file to IMPORTED folder
            End If
            fName = Dir                                       'ready next filename
    Something like this, add to this "map" as you need:
            'This is the section to customize, replace with your own action code as needed
                'create a map here of the cells you want to "add"
                .Range("A7").Value = .Range("A7").Value + sheet7.Range("A7").Value
                .Range("B9").Value = .Range("B9").Value + sheet7.Range("B9").Value
                .Range("C7").Value = .Range("C7").Value + sheet7.Range("C7").Value
    
                wbData.Close False                                'close file
                NR = .Range("A" & .Rows.Count).End(xlUp).Row + 1  'Next row
                Name fPath & fName As fPathDone & fName           'move file to IMPORTED folder
            End If
            fName = Dir                                       'ready next filename
    Last edited by JBeaucaire; 12-27-2019 at 10:16 PM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    RCRod83
    Guest

    Re: Extracting Worksheet from multiple files + consolidated them...

    Wow thanks! Let me play with this and see if I can get it to work. I'll report back. :D

  4. #4
    RCRod83
    Guest

    Re: Extracting Worksheet from multiple files + consolidated them...

    Quick question: It states that 'Sheet7' in your map: "Variable Not Defined"

    \1
    Attached Images Attached Images

  5. #5
    Registered User
    Join Date
    08-26-2012
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    58

    Re: Extracting Worksheet from multiple files + consolidated them...

    Hi,

    can you try once with

    
    Sheets(7)
    instead of sheet7

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Extracting Worksheet from multiple files + consolidated them...

    Mybad! Must attach the sheet7 reference to the opened workbook:
            'This is the section to customize, replace with your own action code as needed
                'create a map here of the cells you want to "add"
                .Range("A7").Value = .Range("A7").Value + wbData.sheet7.Range("A7").Value
                .Range("B9").Value = .Range("B9").Value + wbData.sheet7.Range("B9").Value
                .Range("C7").Value = .Range("C7").Value + wbData.sheet7.Range("C7").Value
    
                wbData.Close False                                'close file
                NR = .Range("A" & .Rows.Count).End(xlUp).Row + 1  'Next row
                Name fPath & fName As fPathDone & fName           'move file to IMPORTED folder
            End If
            fName = Dir                                       'ready next filename

+ 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