TheWennerWoman
Active Member
- Joined
- Aug 1, 2019
- Messages
- 303
- Office Version
- 365
- Platform
- Windows
I have 40 queues to monitor with four sub-queues, so 160. I don't really want to write the below 160 times This is for the first queue (AQ1), the folder structure runs upto AQ40.
Thanks in advance as always
VBA Code:
Sub CountFiles()
Dim strDir As String
Dim fso As Object
Dim objFiles As Object
Dim obj As Object
Dim lngFileCount As Long
strDir = "T:\X1Home\PDF_Poll\AQ1\Test\CREDIT\NONPOP\"
Set fso = CreateObject("Scripting.FileSystemObject")
Set objFiles = fso.GetFolder(strDir).Files
lngFileCount = lngFileCount + objFiles.Count
ThisWorkbook.Worksheets("Sheet1").Range("B8").Value = objFiles.Count
ThisWorkbook.Worksheets("Sheet1").Range("A8").Value = strDir
ThisWorkbook.Worksheets("Sheet1").Range("C8").Value = Now()
strDir = "T:\X1Home\PDF_Poll\AQ1\Test\CREDIT\POP\"
Set fso = CreateObject("Scripting.FileSystemObject")
Set objFiles = fso.GetFolder(strDir).Files
lngFileCount = lngFileCount + objFiles.Count
ThisWorkbook.Worksheets("Sheet1").Range("B9").Value = objFiles.Count
ThisWorkbook.Worksheets("Sheet1").Range("A9").Value = strDir
ThisWorkbook.Worksheets("Sheet1").Range("C9").Value = Now()
strDir = "T:\X1Home\PDF_Poll\AQ1\Test\INVOICE\NONPOP\"
Set fso = CreateObject("Scripting.FileSystemObject")
Set objFiles = fso.GetFolder(strDir).Files
lngFileCount = lngFileCount + objFiles.Count
ThisWorkbook.Worksheets("Sheet1").Range("B10").Value = objFiles.Count
ThisWorkbook.Worksheets("Sheet1").Range("A10").Value = strDir
ThisWorkbook.Worksheets("Sheet1").Range("C10").Value = Now()
strDir = "T:\X1Home\PDF_Poll\AQ1\Test\INVOICE\POP\"
Set fso = CreateObject("Scripting.FileSystemObject")
Set objFiles = fso.GetFolder(strDir).Files
lngFileCount = lngFileCount + objFiles.Count
ThisWorkbook.Worksheets("Sheet1").Range("B11").Value = objFiles.Count
ThisWorkbook.Worksheets("Sheet1").Range("A11").Value = strDir
ThisWorkbook.Worksheets("Sheet1").Range("C11").Value = Now()
End Sub
Thanks in advance as always