![]() |
VBA Code
If LstMinus.Value = -1, then
Do Until iMBizDay = LstMinus.Value is evaluated as Do Until -1 = -1 which, since it's true, will skip the entire Do...Loop structure. If you want to execute the code at least once, you could use iMBizDay = 0 Do ... Loop Until iMBizDay = LstMinus.Value In article , "jacqui" wrote: I have written the following piece of code where LstMinus can equal a value of between -10 and -1. This code works fine for every value other than where LstMinus = -1 then obviously it exits the loop. I understand where I'm going wrong with the code but I'm not sure how to fix it. Can anyone help please? Many thanks Jacqui iMBizDay = -1 dMDate = dDate - 1 Do Until iMBizDay = LstMinus.Value If WeekDay(dMDate) < 7 And WeekDay(dMDate) 1 Then iMBizDay = iMBizDay - 1 dMDate = DateAdd("d", -1, dMDate) Else dMDate = DateAdd("d", -1, dMDate) End If Loop |
All times are GMT +1. The time now is 05:19 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com