View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_5_] Dave Peterson[_5_] is offline
external usenet poster
 
Posts: 1,758
Default Count files in folder

One more way:

Option Explicit
Sub testme()
Dim FSO As Object
Dim myFolder As String

myFolder = "C:\my documents\excel"

Set FSO = CreateObject("Scripting.FileSystemObject")

If FSO.FolderExists(myFolder) Then
activesheet.range("a1").value = FSO.GetFolder(myFolder).Files.Count
End If

End Sub

gmunro wrote:

Hello,

I want to create a macro that will go to a folder, count the excel
documents in it (There will only be excel documents in it if that
helps), go back to my original document and enter the number of files
in a cell.

Is this possible?


--

Dave Peterson