Counting files using Loop
I am trying to count files and using a loop and some
variables to identify the server/directories/subdir.. etc As it loops it keeps coming back with the quantity found in the first loop gyration for all other loop gyrations. The loop does seem to work because it stops in the right spot, based on the DoUntil command, and places a file count number (albeit of the first Loop) in the appropriate cells, also part of the loop cammands. Any suggestions? Here's my cosde. This calls a FileSearch function called CountAllFiles. Sub TestCountFiles() Dim i As Integer i = 1 Do Until IsEmpty(Cells(i, 1)) 'Change this to the directory you want to check. Dim strMyDirectory As String strMyDirectory = "C: /my documents/" & (Cells(i, 1)) ' This holds the total number of files found. Dim lFileTotal As Long ' Call the function. Pass the directory to check. lFileTotal = CountAllFiles(strMyDirectory) ' Display the total files found in on spreadsheet ' in row i, Col H. Cells(i, 8).Value = lFileTotal i = i + 1 Loop End Sub |
All times are GMT +1. The time now is 02:49 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com