"" Then 'is there such a file? Do found1 = found1 + 1 Loop While Dir() <> "" 'are there more such files End If Sheets("DTS Xmissions").Range("C" & i1) = found1 Next i1 I was able to find this using google, but am not sure how to incorporate it, or even if it would work. Code: Dim csvFiles = From csv In Directory.EnumerateFiles("DirectoryPath", Where File.GetCreationTime(csv).Date = Date.Today For Each csvPath In csvFiles Console.WriteLine(csvPath) Next If you are on .NET 2 as commented, you don't have Linq and Directory.EnumerateFiles, then use GetFiles and loops: Code: .">
Most valuable professional
  • Hot Topics

Excel Directory count occurrences

I am currenlty using a "simple" macro to count the number of files in a particular folder. I was wondering if anyone can help me modify/adjust it so it only counts the number of files with today's date. Many thanks in advance! My script: Code: Sub DTSx() Dim srch1 As String, found1 As Integer, i1 As Integer For i1 = 4 To 4 srch1 = "\\root\inbound\" & "*.835" found1 = 0 If Dir(srch1) <> "" Then 'is there such a file? Do found1 = found1 + 1 Loop While Dir() <> "" 'are there more such files End If Sheets("DTS Xmissions").Range("C" & i1) = found1 Next i1 I was able to find this using google, but am not sure how to incorporate it, or even if it would work. Code: Dim csvFiles = From csv In Directory.EnumerateFiles("DirectoryPath", Where File.GetCreationTime(csv).Date = Date.Today For Each csvPath In csvFiles Console.WriteLine(csvPath) Next If you are on .NET 2 as commented, you don't have Linq and Directory.EnumerateFiles, then use GetFiles and loops: Code:

This question generated 24 answers. To proceed to the answers, click here.

This thread is current as of October 17, 2013.

For more resources for Microsoft Excel:

This article includes the following tags:

  • Excel
  • Microsoft Excel