Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank you so much!!
-----Original Message----- Sandy wrote: Thanks for your response! Note that if I try to use GoTo SKIP_FILE on an if statement, the whole thing fails. The code is: Public Function ExportToTemplates() <snip On Error GoTo SKIP_FILE Set dbs = DBEngine.Workspaces(0).Databases(0) <snip FileName = Dir(DBPath & "Templates_Out\*.xls") Do Until FileName = "" 'Put If "div" file language in here If UCase(Left(FileName, 3)) = "DIV" Then GoTo SKIP_FILE Does this line not work for you? An identical functional way would be to have he If UCase(Left(FileName, 3)) = "DIV" Then and a corresponding 'End If' just above the SKIP_FILE line. Of course, you might want to indent the lines within the IF - END IF. Matthew <snip FilePathName = DBPath & "Templates_Out\" & FileName xl.Application.Workbooks.Open FilePathName ' get area code <snip FileCopy FilePathName, ls_destination Kill FilePathName SKIP_FILE: <snip FileName = Dir() Loop <snip End If End Function Thanks again! Sandy -----Original Message----- Sandy wrote: I am looping through files in a directory with a Do Until ... Loop. If there is a file name with "div...".xls in it, I need to skip it and go to the next file. Any suggestions would be greatly appreciated! Sandy It's a bit hard to get specific without some of the code you have already written, but it might look something like this: strFileName = <first filename Do If Left(strFileName,3) < "div" Then <process file somehow ... End If strFileName = <set to next filename Loop Until <condition Hope this helps, Matthew . . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
for loop with if statement | Excel Worksheet Functions | |||
Find loop doesn't loop | Excel Discussion (Misc queries) | |||
Loop Statement through If Not IsEmpty Then Paste into Destination | Excel Discussion (Misc queries) | |||
On Error Resume Next (when next statement is Do Loop ...) | Excel Discussion (Misc queries) | |||
If statement - Loop? | Excel Discussion (Misc queries) |