Consulting

Results 1 to 5 of 5

Thread: Use a master list to run a macro that opens, extracts, and closes multiple workbooks

  1. #1

    Use a master list to run a macro that opens, extracts, and closes multiple workbooks

    I have a master workbook with a list of about 100 items and most of the items also have their own workbook with the name of the item as the name of the workbook. Within each workbook there is a worksheet that has data and I want so extract just a portion of the data into a single sheet in the master workbook. Is there a way to do this with VBA code where it loops through each workbook one at a time by finding the workbook based on the item name in the list and then extract data then close the workbook?

  2. #2
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,639
    If you store the data of the 100 items in 1 worksheet (and there's enough space to do so) your 'problem' doesn't even arise.
    'Structuring precedes coding'.

  3. #3
    Quote Originally Posted by snb View Post
    If you store the data of the 100 items in 1 worksheet (and there's enough space to do so)
    That is actually the goal. How do I automate that from the 100 workbooks? Each item has 60 data points. I need to get 10 of those data points from each of the workbooks into a master sheet.

    The reason I have about 100 workbooks is because I had to pull the data into each of the workbooks with a specific program that didn't give me an option to make one large worksheet of the 100 items into a single workbook.

  4. #4
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,639
    Sub M_snb()
      sn=sheet1.range("A1:A100")
    
      for each it in sn
        sheets.add(,sheets(sheets.count),,"G:\OF\" & it & ".xlsx"
      next
    End Sub
    Why do you provide too little information to answer your question adequately?

  5. #5
    Quote Originally Posted by snb View Post
    Why do you provide too little information to answer your question adequately?
    I thought I had provided enough information. That means I don't have enough knowledge to know what you need to know and I don't know what isn't understood, yet stated, in my posts. I don't need to add sheets. I want to avoid getting 100 sheets into a single workbook. I thought opening a workbook with VBA uses Workbooks.Open

    Rewording my situation -
    I have about 100 workbooks. All closed. Need to use VBA to open each workbook and extract 10 data points from a single sheet in each workbook into a master sheet in a master workbook that has a list of about 100 items in a single column. Each of the about 100 workbooks has the name of the item as the name of the workbook. The data points are in column B in the individual workbooks with the "header" in A. I need to get the data points into rows in the master sheet, corresponding to the item name, and the header will be in a row at the top of the master sheet.

    Is there a way to create a macro with VBA to do that?
    Last edited by Commoner; 10-11-2020 at 06:17 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •