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.