EXCEL-LENCY
Board Regular
- Joined
- Feb 9, 2010
- Messages
- 75
Hello,
I have the code below that opens files in a particular folder... I need it to open them in the order that they are in the file (alphabetical by filename). Is this possible?
Sub AllFiles()
Dim folderPath As String
Dim filename As String
Dim wb As Workbook
folderPath = "C:\SAP Imports\Sales Orders\"
If Right(folderPath, 1) <> "\" Then folderPath = folderPath + "\"
filename = Dir(folderPath & "*.xls")
Do While filename <> ""
Application.ScreenUpdating = False
Set wb = Workbooks.Open(folderPath & filename)
Call Mymacro
filename = Dir
Loop
Application.ScreenUpdating = True
End Sub
Thanks,
Jason
I have the code below that opens files in a particular folder... I need it to open them in the order that they are in the file (alphabetical by filename). Is this possible?
Sub AllFiles()
Dim folderPath As String
Dim filename As String
Dim wb As Workbook
folderPath = "C:\SAP Imports\Sales Orders\"
If Right(folderPath, 1) <> "\" Then folderPath = folderPath + "\"
filename = Dir(folderPath & "*.xls")
Do While filename <> ""
Application.ScreenUpdating = False
Set wb = Workbooks.Open(folderPath & filename)
Call Mymacro
filename = Dir
Loop
Application.ScreenUpdating = True
End Sub
Thanks,
Jason