Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2006

Tip: Looking for answers? Try searching our database.

Do Until with Multiple Conditions

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Butaambala - 21 Jan 2006 11:56 GMT
Hello,

Please help me to make my Do Until Loop work with multiple conditions.
The outcome is correct using just one condtion (either works), but when
I try to use both, the loop goes one too many iterations.

Public Function SetNextDate()
x = 1
Set rng = Sheets("REF").Range("B1",
Sheets("REF").Range("B1").End(xlDown))

Do Until rng.Find(Date + x) Is Nothing And Weekday(Date + x, vbMonday)
< 6
   x = x + 1
Loop
dteNextJulian = Date + x
End Function

Essentially, I want "Date" to increase by one day until "Date + x" is
NOT a weekend day AND "Date + x" is NOT found in a list of special
dates specified in "rng".

Thank you in advance for your help!
Ben.
Toppers - 21 Jan 2006 12:29 GMT
Ben,
           It works OK for me with the data below. It finds 25/01/2006
which meets your conditions. I omitted 22/01/06 (Sunday) and 25/01/06
(Wednesday).

Your last statement should be:

SetNextDate = Date + x NOT dteNextJulian = Date + x  (Typo?!)

(XL2003)

21/01/2006
23/01/2006
24/01/2006
26/01/2006
28/01/2006
29/01/2006
30/01/2006
31/01/2006
01/02/2006
02/02/2006

> Hello,
>
[quoted text clipped - 20 lines]
> Thank you in advance for your help!
> Ben.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.