Solved

vba to exclude Saturday and Sunday from date calculation

Posted on 2012-03-28
2
348 Views
Last Modified: 2012-06-21
I have a spreadsheet where I need to calculate the number of minutes between to time fields and to include weekdays in the calculation IF the oldest time in the queue is a day prior to the current day.   How would I do this? the formula is in ( i12).  columns g & H are hidden I have  attached a sample of the spreadsheet

Thank You
2012-Research-Queue-Checkpoint.xls
0
Comment
Question by:eyes59
  • 2
2 Comments
 
LVL 80

Accepted Solution

by:
byundt earned 500 total points
ID: 37779679
The NETWORKDAYS function returns the number of weekdays between two dates. If both dates are the same, it returns 1. So neglecting any correction for starting time, you might use:
=IF(H12="","",(NETWORKDAYS(B12,E12)-1+H12-C12)*1440)

The above formula is probably not sophisticated enough for your real problem. Among other things, it can't return a negative number. And it ignores your special handling for Mondays. But if you can give some sample data and expected results, I can fine-tune the formula to suit.

As an added bonus, NETWORKDAYS can exclude a list of holidays that you choose from the calculation. That feature may or may not come into play for your real situation--but for many problems it does.
0
 
LVL 80

Expert Comment

by:byundt
ID: 37781490
eyes59,
Please continue to post in this thread if you need help with implementation. Doing so adds value to the question in the Experts Exchange database.

Brad
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

A2 = A1 That kind of cell reference is relative.  If you copy it from A2 to B2, then B2 will get this: B2 = B1 That's all fine and good, but if you then insert a new row above row 2, you'll find: A3 = A1 B3 = B1 This is intentional. …
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now