I have a program that creates backups after format: <name>_<date>
Some of them have more backups, some of them have none.
There are kept up to 3 backups with same name but different dates.
I have an excel table that contains names and a script that checks if there is a backup or not, and colors the cell after the result.
I want to improve the script, so it would check if the backup is outdated (older than 30 days).
I have got the idea, but I ran into a problem. If there are multiple backups of the same name, I cant figure out, how to make it compare the newest of them.
the script:
'auto check if backup exists - on click
file = Dir("<filepath>")
Do While file <> ""
myBool = False
backup = Right(backup, 6)
If InStr(file, backup) > 0 Then
If now - FileDateTime(file) > 30 Then 'this is where I have the problem... how do I make it grab the newest of the backups?
'outdated
End If
myBool = True
ActiveCell.Interior.ColorIndex = "35"
Exit Do
End If
file = Dir
Loop
If Not myBool Then
ActiveCell.Interior.ColorIndex = "22"
End If