Skip to content

Instantly share code, notes, and snippets.

@ndthanh
Created February 15, 2017 12:56
Show Gist options
  • Select an option

  • Save ndthanh/e29287455f03aed6fe466f1b40eb1ed1 to your computer and use it in GitHub Desktop.

Select an option

Save ndthanh/e29287455f03aed6fe466f1b40eb1ed1 to your computer and use it in GitHub Desktop.
Function CountFilesInFolder(strDir As String, Optional strType As String)
Dim file As Variant, i As Integer
If Left(strDir, 1) <> "\" Then strDir = strDir & "\"
file = Dir(strDir & strType)
While (file <> "")
i = i + 1
file = Dir
Wend
CountFilesInFolder = i
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment