How to loop through folders and their sub folders in vba. I tried using this code but its not working for me. my folder variable gets the correct name i.e. "d:\neha" but my variable sf for subfolder is not working
VBA Code:
Sub ShowFolderList()
Dim fso, folder, f1, sf
Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder("d:\neha")
Set sf = folder.subfolders
For Each f1 In sf
If f1.name = "n1" Then
MsgBox " found"
End If
Next
End Sub