![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Apr 2002
Posts: 16
|
How can I call a vba function that I can use like the built in functions? for example I need the number of weekdays between two dates, similar to =DAYS360() which returns total number of days.
|
|
|
|
|
|
#2 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
Theoretically you can use the worksheetfunction class, but it was misfiring on my pc. So I settled on:
Code:
MsgBox Evaluate("=DAYS360(TODAY(),TODAY()-1)")
|
|
|
|
|
|
#3 |
|
New Member
Join Date: Apr 2002
Posts: 16
|
Thanks for the quick reply, but I'm not sure we're on the same track. I have created a function for the worksheet called GetWorkDays that takes two parameters, start date and end date. In a cell I want to do something like =GetWorkDays(4/26/2002,5/26/2002) and get the result in the cell.
|
|
|
|
|
|
#4 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
Oh. Whoops
=Networkdays() _________________ Cheers, NateO [ This Message was edited by: NateO on 2002-04-26 10:38 ] |
|
|
|
|
|
#5 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
You would do something like this:
To use this in your worksheet you would simply put in a cell: =GetWorkDays(4/26/2002,5/26/2002) HTH |
|
|
|
|
|
#6 |
|
New Member
Join Date: Apr 2002
Posts: 41
|
Happydog
You don't really need to create a function for use in the worksheet. Use Networkdays. You do, however, need to have the Analysis Toolpak installed. To do this select Tools/AddIns and then select Analysis Toolpak. Once this is done, you will be able to us e the Networkdays function. Say you have a dtae in A1 and another in A2, in A3 enter =Networkdays(A1,A2) and the result will be the number of workdays between the two (A1 is start, A2 is end). If you want to range over a persiod containing public holidays, you may also allow for them. List the holidays, say in H1 to H5, the formula then becomes =Networkdays(A1,A2,H1:H5). Any help? Regards Robb__ |
|
|
|
|
|
#7 |
|
New Member
Join Date: Apr 2002
Posts: 16
|
Nate/Robb, I am looking into that as a possible solution. Will this work for other users if they do not have the Analysis ToolPak installed?
Mark, I tried this and it does not seem to work for me. I'm just getting the #NAME? Thanks. |
|
|
|
|
|
#8 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
Also take note, if you want to hard code the date's you'll need to do so using Excel's date serial number methodology, which is quite a bit of fun.
I didn't realize this function was of the analysis toolpak variety. It comes with XL, just go tools->add ins, check the appropriate box and you're in like a dirty shirt, others should replicate this procedure... _________________ Cheers, NateO [ This Message was edited by: NateO on 2002-04-26 10:37 ] |
|
|
|
|
|
#9 |
|
New Member
Join Date: Apr 2002
Posts: 16
|
All right that will work then.
Thanks everyone. |
|
|
|
|
|
#10 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
Quote:
Take it easy. |
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|