Brainstorming a way to run a Macro through all excel files in a folder

Wamhoi

New Member
Joined
Mar 4, 2011
Messages
48
I want a run a Macro that opens each workbook(with different wk Names) in a designated share folder. Filter the data and copy the information to a Master workbook that contains the macro. I'm not sure where to begin coding. Does anyone know a site I can begin to learn or do you have a basic template you've worked on in the past that can help me.

Thanks,
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Not sure what you mean by a 'share' folder but there are various ways you could loop through all the files in a folder.

Here's a simple example to get all the files with an extension that includes 'xl' and put them on a worksheet.
Code:
Option Explicit
 
Sub AllXL()
Dim strFileName As String
Dim strPath As String
Dim strExt As String
Dim rng As Range
 
    strExt = "xl"
    strPath = "C:\" '
    
    Set rng = Range("A1")
    
    strFileName = Dir(strPath & "*.*" & strExt & "*")
    
    Do
        
        
        rng.Value = strFileName
        
        Set rng = rng.Offset(1)
    
        strFileName = Dir()
        
    Loop Until strFileName = ""
    
End Sub
The next step would be to add code to open the files an run your code.

Mind you the first step should probably be to write the code you want to run on each file, and write it in a way so it will work for them all.:)
 
Upvote 0

Forum statistics

Threads
1,224,516
Messages
6,179,231
Members
452,898
Latest member
Capolavoro009

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