Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Do Until loop with if statement

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
for loop with if statement Steve Excel Worksheet Functions 1 February 17th 10 07:56 PM
Find loop doesn't loop JSnow Excel Discussion (Misc queries) 2 June 24th 09 08:28 PM
Loop Statement through If Not IsEmpty Then Paste into Destination Dandelo Excel Discussion (Misc queries) 7 July 15th 08 10:29 PM
On Error Resume Next (when next statement is Do Loop ...) EagleOne Excel Discussion (Misc queries) 2 September 26th 06 03:26 PM
If statement - Loop? George Excel Discussion (Misc queries) 1 March 14th 06 07:06 AM


All times are GMT +1. The time now is 03:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"