Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Counting Loop - Please help | Excel Discussion (Misc queries) | |||
open files in loop with date order | Excel Discussion (Misc queries) | |||
Counting files using Loop | Excel Programming | |||
Loop thru files in DIR, delete worksheets & reset worksheet Name property?? | Excel Programming | |||
Loop thru multiple files - Modify worksheet visible property | Excel Programming |