[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 239
  • 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?
0
Conernesto
Asked:
Conernesto
  • 3
1 Solution
 
GrahamSkanCommented:
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$()
    Loop
   MsgBox "There are " & iCount & " relevant files in the folder"
End Sub

Open in new window

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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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