Link to home
Start Free TrialLog in
Avatar of williamss132
williamss132

asked on

Tons of If statements

I have to create if statements for 117 files that are being reviewed.  I wonder if there is a more consise way to write this:
The age of the reports changes.  RPT 1-3 are 60 mins, RPT 4-63 are 120 mins...

For Each file in f.Files
age = DateDiff("n", file.DateLastModified, Now)
'60 Minute Reports
If ((age > 60) and (lcase(right(file.name,4) = ".enc")) and InStr(1,file.name, RPT1,1) = 1) Then
      old_file_found = 1
      old_file_name = old_file_name & vbCrlf & file & vbCr
Elseif ((age > 60) and (lcase(right(file.name,4) = ".enc")) and InStr(1,file.name, RPT2,1) = 1) Then
      old_file_found = 1
      old_file_name = old_file_name & vbCrlf & file & vbCr
Elseif ((age > 60) and (lcase(right(file.name,4) = ".enc")) and InStr(1,file.name, RPT3,1) = 1) Then
      old_file_found = 1
      old_file_name = old_file_name & vbCrlf & file & vbCr
'120 Minute Reports
Elseif ((age > 120) and (lcase(right(file.name,4) = ".enc")) and InStr(1,file.name, RPT4,1) = 1) Then
      old_file_found = 1
      old_file_name = old_file_name & vbCrlf & file & vbCr
...END STATEMENT hundereds of lines later...
SOLUTION
Avatar of Kent Dyer
Kent Dyer
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of williamss132
williamss132

ASKER

Thanks Experts!!