End Select Statement - Error

I have this code:

           Select Case fileage
                Case 1,2,3
                   'check the known 60min reports
                   for i=1 to 3
                           If ((age > 60) and (lcase(right(file.name,4) = ".enc")) and InStr(1,file.name, RPT(i),1)=1) then
                                    old_file_found = 1
                                    old_file_name = old_file_name & vbCrlf & file.name & vbCr
                                    exit for
                           end if
                    next
                Case 4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68
                   'check the known 120min reports
                   for i=4 to 68
                           If ((age > 120) and (lcase(right(file.name,4) = ".enc")) and InStr(1,file.name, RPT(i),1)=1) then
                                    old_file_found = 1
                                    old_file_name = old_file_name & vbCrlf & file.name & vbCr
                                    exit for
                           end if
                    next
                Case 69,70,71,72,73,74,75,76
                   'check the known 180min reports
                   for i=69 to 76
                           If ((age > 180) and (lcase(right(file.name,4) = ".enc")) and InStr(1,file.name, RPT(i),1)=1) then
                                    old_file_found = 1
                                    old_file_name = old_file_name & vbCrlf & file.name & vbCr
                                    exit for
                           end if
                    next
               Case 77,78,79
                   'check the known 720min reports
                   for i=77 to 79
                           If ((age > 720) and (lcase(right(file.name,4) = ".enc")) and InStr(1,file.name, RPT(i),1)=1) then
                                    old_file_found = 1
                                    old_file_name = old_file_name & vbCrlf & file.name & vbCr
                                    exit for
                          end if
                   next  
end select
next fileage

When I check it I get error - Expected End of Statement on line with "end select"
williamss132Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

redeux-techCommented:
Where is the For Loop that the next fileage statement refers to?
0
williamss132Author Commented:
sorry, didn't include that.  This is above the Case statement:

for each file in f.Files
0
williamss132Author Commented:
Fill code attached.
oldestfile-117.txt
0
Become a CompTIA Certified Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Martin LissOlder than dirtCommented:
I believe the last line should be Next File (not fileage) or just Next.

Also you can change lines like Case 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68

to

Case 4 To 68
0
redeux-techCommented:
Well that line should be "next file"  not "next fileage"
0
williamss132Author Commented:
When I change from next fileage to next file, I still get the error:
'Expected end of statement'

When I change to range - 77 to 79  instead of 77,78,79I get error:  on that line - 'Expected end of statement'
0
Martin LissOlder than dirtCommented:
Can you copy/paste the whole sub or at least the complete For/Next loop? The code you showed above has things like "end if" rather than "End If" so it looks like you manually typed all that into your question.
0
williamss132Author Commented:
My whole code is attached above.
0
Martin LissOlder than dirtCommented:
Again, did you copy the code from your workbook and paste it into the question? I ask because the code in your workbook has "End If" (first letter of each word capitalized) and here it's not, and it's a waste of time for me to look at the code you posted since if manually entered it may contain mistakes.
0
williamss132Author Commented:
an expert wrote it in my last question.
0
Martin LissOlder than dirtCommented:
That may be true but I don't understand why you won't copy the code from your workbook and paste it here.
0
williamss132Author Commented:
I posted the text file above.  this is my entire program.
0
Martin LissOlder than dirtCommented:
Please attach your workbook.
0
williamss132Author Commented:
what do you mean by workbook?  I don't have anything else other than the code
0
Martin LissOlder than dirtCommented:
I'm so sorry. For some reason I assumed this was Excel. In any case the following where I added line 1, and changed lines 12 and 42 does not give any errors.


For Each File In f.File
           Select Case fileage
                Case 1, 2, 3
                   'check the known 60min reports
                   For i = 1 To 3
                           If ((age > 60) And (LCase(Right(File.Name, 4) = ".enc")) And InStr(1, File.Name, RPT(i), 1) = 1) Then
                                    old_file_found = 1
                                    old_file_name = old_file_name & vbCrLf & File.Name & vbCr
                                    Exit For
                           End If
                    Next
'                Case 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68
                Case 4 To 68
                
                   'check the known 120min reports
                   For i = 4 To 68
                           If ((age > 120) And (LCase(Right(File.Name, 4) = ".enc")) And InStr(1, File.Name, RPT(i), 1) = 1) Then
                                    old_file_found = 1
                                    old_file_name = old_file_name & vbCrLf & File.Name & vbCr
                                    Exit For
                           End If
                    Next
                Case 69, 70, 71, 72, 73, 74, 75, 76
                   'check the known 180min reports
                   For i = 69 To 76
                           If ((age > 180) And (LCase(Right(File.Name, 4) = ".enc")) And InStr(1, File.Name, RPT(i), 1) = 1) Then
                                    old_file_found = 1
                                    old_file_name = old_file_name & vbCrLf & File.Name & vbCr
                                    Exit For
                           End If
                    Next
               Case 77, 78, 79
                   'check the known 720min reports
                   For i = 77 To 79
                           If ((age > 720) And (LCase(Right(File.Name, 4) = ".enc")) And InStr(1, File.Name, RPT(i), 1) = 1) Then
                                    old_file_found = 1
                                    old_file_name = old_file_name & vbCrLf & File.Name & vbCr
                                    Exit For
                          End If
                   Next
End Select
Next

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
williamss132Author Commented:
OK.  So no more errors, but I don't get any email when I run it.  

I have files .enc that are old in the folder
0
Martin LissOlder than dirtCommented:
Okay, since I solved the original problem you should close this question and ask a new one.
0
williamss132Author Commented:
Thanks for your help!
0
Martin LissOlder than dirtCommented:
You're welcome and I'm glad I was able to help.

Marty - MVP 2009 to 2013
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.