+ Reply to Thread
Results 1 to 4 of 4

Calculate networkdays using vba .formula

  1. #1
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Calculate networkdays using vba .formula

    Hi,

    I am trying to calculate the networkdays between two dates using vba. I am inserting a formula into the worksheet but for some reason the value i calculate is "0". When i do the calculation manually i get the right value.........any ideas.........see enclosed excel file.
    Attached Files Attached Files

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,412

    Re: Calculate networkdays using vba .formula

    I've always found that the easiest way to get a formula into VBA is to get it to work in the spreadsheet first ... which you have done.

    So, select the cell with the working formula and start recording a macro. Press F2 to go into Edit mode and press Enter to re-confirm the formula. Stop the macro recording. You now have the code for the formula in the active cell. Modify that for the cell(s) you want and you're done. That will reproduce the formula and adjust the ranges automatically.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    12-02-2012
    Location
    Delhi
    MS-Off Ver
    Excel 2003,2007
    Posts
    17

    Re: Calculate networkdays using vba .formula

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Keep it in double quotes. it will give you the right results.

    Thanks

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,412

    Re: Calculate networkdays using vba .formula

    Please Login or Register  to view this content.

    Or, with your code:

    Please Login or Register  to view this content.

    Regards, TMS

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1