Hi all,
I am having trouble taking my macro from a basic single loop to multi-loop based on certain conditions. The first loop below works properly but I cannot get a second and third identical loop to work without giving a "Loop Without Do" error. In my second and third loops I am replacing the "var" variable with var2 and var3, otherwise the code and variables remain the same.
I've searched multiple forums but I cannot identify where I have gone wrong. Any help would be great!
I am having trouble taking my macro from a basic single loop to multi-loop based on certain conditions. The first loop below works properly but I cannot get a second and third identical loop to work without giving a "Loop Without Do" error. In my second and third loops I am replacing the "var" variable with var2 and var3, otherwise the code and variables remain the same.
I've searched multiple forums but I cannot identify where I have gone wrong. Any help would be great!
Code:
' Set path to folder
Const MyPath As String = "c:/example/
' Get first file in folder that includes var variable in name
MyFile = Dir(MyPath & "*" & var & "*")
' Loop through until no files remain
Do While Len(MyFile) > 0
' Set variable as last modified date of current file
LMD = Format(FileDateTime(MyPath & MyFile), "Short Date")
' Compare last modified date of file to input date from user, if equal, add 1 to counter
If LMD = dteFile Then
ctr = ctr + 1
End If
' Get next file from the folder
MyFile = Dir
Loop
' Get first file in folder that includes var2 variable in name
MyFile = Dir(MyPath & "*" & var2 & "*")
' Loop through until no files remain
Do While (Len(MyFile) > 0 And Range("B1") > 24)