+ Reply to Thread
Results 1 to 12 of 12

Having difficulties with Networkdays formula in my macro

  1. #1
    Forum Contributor
    Join Date
    05-13-2012
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2010
    Posts
    378

    Question Having difficulties with Networkdays formula in my macro

    I have a column that I need to add a networkdays formula to. I started to create some code that I thought would work.

    Please Login or Register  to view this content.
    However, I get a syntax error with the formula. What is the best way to resolve this?



    Thanks!!

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Having difficulties with Networkdays formula in my macro

    Your code has a host of problems.

    What formula would you enter in the cells manually?
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Contributor
    Join Date
    05-13-2012
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: Having difficulties with Networkdays formula in my macro

    I would manually enter

    =Networkdays(K2,L3)

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Having difficulties with Networkdays formula in my macro

    What cell would you enter that exact formula in -- N2 or N3?

  5. #5
    Forum Contributor
    Join Date
    05-13-2012
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: Having difficulties with Networkdays formula in my macro

    I keyed the wrong formula...it should be...

    =networkdays(K2,L2)

    And I would have this in N2. I used to the auto fill this down the column. However, I would like to create a code to accomplish the same thing.

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Having difficulties with Networkdays formula in my macro

    Untested:

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    05-13-2012
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: Having difficulties with Networkdays formula in my macro

    This works great!!! How do I incorporate holidays into this formula?

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Having difficulties with Networkdays formula in my macro

    How would you do it manually?

  9. #9
    Forum Contributor
    Join Date
    05-13-2012
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: Having difficulties with Networkdays formula in my macro

    I would put the holiday(s) is a blank cell and then add to the formula.

    Ex.
    Put 7/4/2012 is B22
    =Networkdays(K2,L2,$B$22)

    Then if I had multiple days...

    B22 to B25
    =Networkdays=(K2,L2,$B$22:$B$25)

    ---------- Post added at 12:25 PM ---------- Previous post was at 12:25 PM ----------

    But is there a way to use your previous formula but then add the actual date(s)?

  10. #10
    Forum Contributor
    Join Date
    05-13-2012
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: Having difficulties with Networkdays formula in my macro

    I have uploaded a sample worksheet of the data I am working with. As you can see the first record actual went to the vendor for repair(O2), came back from the vendor(P2), then went back to vendor(Q2), and then came back from the vendor(R2) and in T2 I used the following formula to calculate the Net work days.

    =Networkdays(O2,R2)

    Then the second record only went to the vendor once for repair, so the formula I used in T3 is...

    =Networkdays(O3,P3)

    How can I write a code that addresses these types of variables?
    Attached Files Attached Files

  11. #11
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Having difficulties with Networkdays formula in my macro

    =networkdays(O2, max(P2, R2, ...))

  12. #12
    Forum Contributor
    Join Date
    05-13-2012
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: Having difficulties with Networkdays formula in my macro

    I have another question...If the device goes to the vendor and returned then I have been subtracting 2 for the number of days in transit. Then if the the device goes to vendor, then returned, then is a repeat to vendor and repeat return from vendor, I subtract 4 for the number of days in transit...how can I modify this code for those conditions?

    ---------- Post added at 04:13 PM ---------- Previous post was at 04:10 PM ----------

    The repeat repairs worksheet I posted previously is an example of what I am talking about...

    Previously, I would have manually entered this formula in the Moto TAT column for the first record...

    =Networkdays(O2,R2)-4

    Then I would enter this formula in the Moto TAT column for the second record...

    =Networkdays(O2,P2)-2

+ 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