sorting through the folder using macro

sisi001

New Member
Joined
Jun 24, 2011
Messages
10
Can anyone please help me with a macro code that can:

go through the folder with path (D:\user\desktop\foldername) and find files with name that contains "xxx_dataspecs.xls" in its name. and once it finds that name, it needs to go through my macro code "architecture" and once done with the code, find another file to run again. It needs to do this processuntil it runs out of files with that name in that folder....


Please please please help me!!!!

Thank You in advance.
sisi001
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Try like this

Code:
Sub DoFiles()
Dim MyFolder As String
Dim MyFile As String
MyFolder = "D:\user\desktop\foldername"
MyFile = Dir(MyFolder & "*_dataspecs.xls")
Do While MyFile <> ""
    Workbooks.Open Filename:=MyFolder & "\" & MyFile
'
' do summat here
'
    ActiveWorkbook.Close savechanges:=True
    MyFile = Dir
Loop
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,547
Messages
6,179,436
Members
452,915
Latest member
hannnahheileen

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