Hi Guys
Can anyone please explain me the following line? What will it return and why?
![]()
i=DateAdd("d", Choose(Weekday(Date), 1, 1, 1, 1, 1, 3, 2), Date)
Hi Guys
Can anyone please explain me the following line? What will it return and why?
![]()
i=DateAdd("d", Choose(Weekday(Date), 1, 1, 1, 1, 1, 3, 2), Date)
well the choose bit will return the addition required to give the next working day ignoring sat and sun
"Unless otherwise stated all my comments are directed at OP"
Mojito connoisseur and now happily retired
where does code go ?
look here
how to insert code
how to enter array formula
why use -- in sumproduct
recommended reading
wiki Mojito
how to say no convincingly
most important thing you need
Martin Wilson: SPV
and RSMBC
Gives you todays date![]()
Date
gives you a number 1-7 for the day of the week with Sunday being 1, Saturday 7![]()
Weekday(date)
The choose function:
So![]()
Syntax Choose(index, choice-1[, choice-2, ... [, choice-n]]) The Choose function syntax has these parts: Part Description index Required. Numeric expression or field that results in a value between 1 and the number of available choices. choice Required. Variant expression containing one of the possible choices. Remarks Choose returns a value from the list of choices based on the value of index. If index is 1, Choose returns the first choice in the list; if index is 2, it returns the second choice, and so on.
will pick from the list of numbers, the one with the position that corresponds to the current weekday number.![]()
Choose(weekday(Date),1,1,1,1,1,3,2)
So Sunday - Thursday gives 1, Friday gives 3, Saturday gives 2.
Dateadd("d",A,B)
will add A days to the date in B.
i.e. the formula gives you the next working day, which is a bit redundant, as you can just use:
worksheetfunction.workday(date,1)
instead!
Thanks but if we want to ignore bank holidays as well then how to modify it?
With the workday function you can add a third argument with a list of holidays to skip as well.
Can you please tell me how can use Workday function and how to list the bank holidays ?
Mnay Thanks for your help so far.
Please see attached the bank holidays list for 2014 and 2015.. Thanks
in your example, you would use:
=WORKDAY(TODAY(),1,B2:B17
Ok but how to exclude weekends like in choose function??
The clue is in the function name.![]()
Everyone who confuses correlation and causation ends up dead.
ok. but it gives me error function not defined.
so basically i want to find the next working days excluding weekends and bank holidays .. how this can be done?
If you are using 2003 you need the Analysis Toolpak installed.
I have added the reference atpvbaen.xls and now it gives me Type mismatcch error at msgbox j..
![]()
j = WORKDAY(Date, 1, "B2:B17") MsgBox j
Its already installed .. so now what shall i do?
The last parameter needs to be a range object, not the address of a range.
Yes its been done. Many Thanks
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks