trprasad78
Member
I have code which work fine till subfolder, but it not working subfolder under folders.
i got the link from chandoo.org forum
http://www.cpearson.com/excel/recursionandfso.htm
but i dont know where to modify , please help me to modify the below code.
i got the link from chandoo.org forum
http://www.cpearson.com/excel/recursionandfso.htm
but i dont know where to modify , please help me to modify the below code.
Code:
Sub RunMacroInSubfolders()
Dim objFSO As Object
Dim objFolder As Object
Dim objSubFolder As Object
Dim objFile As Object
Dim MyFolder As String
Dim wkbOpen As Workbook
Dim wkb As Workbook
Dim wks As Worksheet
Dim CalcMode As Long
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
.EnableEvents = False
End With
'Change the path accordingly
MyFolder = "F:\Dec'16"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(MyFolder)
Set wkb = ActiveWorkbook
Set wks = ActiveSheet
For Each objSubFolder In objFolder.SubFolders
For Each objFile In objSubFolder.Files
Set wkbOpen = Workbooks.Open(objFile.path)
'Your code here
Call Create_ExportSheet
wkbOpen.Close SaveChanges:=True
Next objFile
Next objSubFolder
With Application
.Calculation = CalcMode
.ScreenUpdating = True
.EnableEvents = True
End With
MsgBox "Completed...", vbInformation
End Sub