counting excel files

  • Thread starter Thread starter dstiefe
  • Start date Start date
D

dstiefe

How do I count excel files that are not open

I want to put excel files in a folder ...then I want to first count the
number of files that are in the folder...

then open them

Thank you
 
One way is to use DIR with a loop....

Sub Macro()
Dim strFolder As String, strFile As String
Dim intCount As Integer
strFolder = "d:\"
strFile = Dir(strFolder & "*.xls", vbNormal)
Do While strFile <> ""
intCount = intCount + 1
strFile = Dir
Loop
MsgBox intCount & " files found"
End Sub

If this post helps click Yes
 
Back
Top