[file] count files in specific folder and display the number into 1 cel

I am trying to know how many files there are in 1 specific folder with .xls extension. I read hundreds of examples with message boxes, but that is not what I'm looking for. I just want to have the number displayed into 1 cel.

Is there someone who likes to help me with that please? I can not post any attempts because I can not get started :-(

best regards, E.

This question is related to file vba xls

The answer is


Try below code :

Assign the path of the folder to variable FolderPath before running the below code.

Sub sample()

    Dim FolderPath As String, path As String, count As Integer
    FolderPath = "C:\Documents and Settings\Santosh\Desktop"

    path = FolderPath & "\*.xls"

    Filename = Dir(path)

    Do While Filename <> ""
       count = count + 1
        Filename = Dir()
    Loop

    Range("Q8").Value = count
    'MsgBox count & " : files found in folder"
End Sub

Examples related to file

Gradle - Move a folder from ABC to XYZ Difference between opening a file in binary vs text Angular: How to download a file from HttpClient? Python error message io.UnsupportedOperation: not readable java.io.FileNotFoundException: class path resource cannot be opened because it does not exist Writing JSON object to a JSON file with fs.writeFileSync How to read/write files in .Net Core? How to write to a CSV line by line? Writing a dictionary to a text file? What are the pros and cons of parquet format compared to other formats?

Examples related to vba

Copy filtered data to another sheet using VBA Better way to find last used row Check if a value is in an array or not with Excel VBA Creating an Array from a Range in VBA Excel: macro to export worksheet as CSV file without leaving my current Excel sheet VBA: Convert Text to Number What's the difference between "end" and "exit sub" in VBA? Rename Excel Sheet with VBA Macro Extract Data from PDF and Add to Worksheet Quicker way to get all unique values of a column in VBA?

Examples related to xls

Export to xls using angularjs How can I quickly and easily convert spreadsheet data to JSON? count files in specific folder and display the number into 1 cel xls to csv converter How to parse Excel (XLS) file in Javascript/HTML5 Converting JSON to XLS/CSV in Java Importing Excel files into R, xlsx or xls .NET Excel Library that can read/write .xls files Reading/parsing Excel (xls) files with Python How to change pivot table data source in Excel?