Sub CountFiles()
    Dim strDir As String
    Dim fso As Object
    Dim objFiles As Object
    Dim obj As Object
    Dim lngFileCount As Long
        
    strDir = "C:\Users\EXCEL.Admin-PC\Downloads"
    
    Set fso = CreateObject("Scripting.FileSystemObject")
    
    'Set objFiles = fso.GetFolder(strDir).Files
    Set objFiles = fso.GetFolder(strDir).subFolders
    
    lngFileCount = objFiles.Count
    
    MsgBox lngFileCount     'Total number of files
    
    
   
    

    Set objFiles = Nothing
    Set fso = Nothing
    Set obj = Nothing
    
End Sub