using macro to collect data into a workbook

lintruthy

Board Regular
Joined
Dec 21, 2016
Messages
54
how can I use macro to automatically put two sets (like name and score) of data from many workbooks (like 100) into a table in one other workbook.
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
to process all files in a folder you could use
Code:
Sub processWorkbooks()
'for this to compile
'set a reference to Microsoft Scripting Runtime

    Dim fso         As Object
    Dim topFolder   As Scripting.folder
    Dim wbFile      As Scripting.file
    Dim wb          As Workbook
    
    'enter your path to the folder containing the workbooks
    Const top As String = "D:\users\ties\Documents\MrExcel\982030"
    
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set topFolder = fso.GetFolder(top)
    
    For Each wbFile In topFolder.Files
        Workbooks.Open wbFile
        Set wb = Workbooks(Workbooks.Count)
        '... process wb
        wb.Close False  'don't save changes
    Next wbFile
End Sub
 
Upvote 0
In vbe
Click References on the Project menu and select the Microsoft Scripting Runtime.
Now it should recognize scripting objects.
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,249
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top