Improve company productivity with a Business Account.Sign Up

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 243
  • Last Modified:

Folder contents

How do I find the number of items in a folder? For example if the folder has 100 Excel worksheets, how can I find this?
  • 3
1 Solution
You could try a macro like this:
Sub ListXlFiles()
    Dim strFileName As String
    Dim strFolder As String
    Dim iCount As Integer
    strFolder = "C:\MyFolder"
    strFileName = Dir$(strFolder & "\*.xl")
    Do Until strFileName = ""
        iCount = iCount + 1
        strFileName = Dir$()
   MsgBox "There are " & iCount & " relevant files in the folder"
End Sub

Open in new window

Note that a Worksheet is a part of a Workbook file. It is not a stand-alone entity.
ConernestoAuthor Commented:
I really meant the number of workbooks. The extension of these particular workbooks is .xsl
OK see if it works. It should look for most types of Excel file.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now