Solved

Folder contents

Posted on 2013-12-05
4
213 Views
Last Modified: 2013-12-06
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
Comment
Question by:Conernesto
  • 3
4 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
ID: 39699804
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
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 39699811
Note that a Worksheet is a part of a Workbook file. It is not a stand-alone entity.
0
 

Author Comment

by:Conernesto
ID: 39699816
I really meant the number of workbooks. The extension of these particular workbooks is .xsl
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 39699824
OK see if it works. It should look for most types of Excel file.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question