Hi Ken,
I am new in this group. I am not able to find out that how can i post a fresh post please let me know regarding this. I have a query regarding VBA coding I have tried but getting error... Can you please what is problem with coding.. getting error at below colored part
Thanks & Best Regards
VJ singh
I am new in this group. I am not able to find out that how can i post a fresh post please let me know regarding this. I have a query regarding VBA coding I have tried but getting error... Can you please what is problem with coding.. getting error at below colored part
Code:
Sub count_files()
Dim Fso As FileSystemObject
Dim Str As String
Dim FldPath As String
Dim fldr As Folder
Dim Fl As File
Dim SubFldrs As Object
Set Fso = CreateObject("Scripting.FileSystemObject")
Str = VBA.InputBox("Enter file format you want to count or leave blank for each file", "File Format")
Application.FileDialog(msoFileDialogFolderPicker).Show
FldPath = Application.FileDialog(msoFileDialogFolderPicker).SelectedItems(1) & " \"
Set fldr = Fso.GetFolder(FldPath)
Set SubFldrs = Fso.GetFolder(FldPath).SubFolders
Dim i As Integer
i = 0
[COLOR=#008000]For Each Fl In fldr.Files[/COLOR]
If Str = "" Then
i = i + 1
ElseIf UCase(Mid(Fl.Path, InStrRev(Fl.Path, ".") + 1, Len(Fl.Path))) = UCase(Str) Then
i = i + 1
Else
End If
Next Fl
Dim fld1 As Folder
For Each fld1 In SubFldrs
Dim fl1 As File
For Each fl1 In fld1.Files
If Str = "" Then
i = i + 1
ElseIf UCase(Mid(Fl.Path, InStrRev(Fl.Path, ".") + 1, Len(Fl.Path))) = UCase(Str) Then
i = i + 1
Else
End If
Next fl1
Next fld1
MsgBox i
End Sub
Thanks & Best Regards
VJ singh
Last edited by a moderator: