Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 16
Default Extrapolating the number of days

I was wondering how I would extrapolate how many days and what days of the
week are within a range span. A scenario like...

Cell E13 Cell F13
01/26/2007 3:41 PM 01/29/2007 12:41 PM

Between the two dates are Friday, Saturday, Sunday, and Monday or
numerically 6, 7, 1, 2 for a total of four days but really 2 days and 21
hours.

The VBA code I'm thinking of is this...

dStart = Range("E13")
dEnd = Range("F13")
Set dCount = 0
Set hCount = 0
Set mCount = 0

For Each Weekday(Date) in dStart to dEnd
Set dCount = Weekdays(Days) ***what do i do here to get the result?
Set hCount = Weekdays(Hours) ***what do i do here to get the result?
Set mCount = Weekdays(Minutes) ***what do i do here to get the result?
MsgBox "There are " & dCount & " Days and " & hCount & " Hours and " &
mCount & " Minutes in this selection boss"


As you can see I'm a real novice and I am quite certain I'm all sorts of
wrong but I have the idea and I'm wondering how I can complete it.


Thanks In Advance,
Fred



  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 149
Default Extrapolating the number of days

Lots of possible approaches, here is one:

Sub CalcElapsed()
Dim dtmStart As Date
Dim dtmEnd As Date
Dim iDays As Integer
Dim iHours As Integer
Dim iMinutes As Integer
Dim lngTotalMinutes As Long

dtmStart = ActiveSheet.Range("B40")
dtmEnd = ActiveSheet.Range("C40")

lngTotalMinutes = DateDiff("n", dtmStart, dtmEnd)
iMinutes = lngTotalMinutes Mod 60
iHours = Fix(lngTotalMinutes / 60) '60 min/hour
iDays = Fix(lngTotalMinutes / 3600) '3600 min/day

MsgBox iDays & " days, " & iHours & " hours, " & iMinutes & " minutes
elapsed."
End Sub

HTH,


"Fred "Djinn" Holstings"
wrote in message ...
I was wondering how I would extrapolate how many days and what days of the
week are within a range span. A scenario like...

Cell E13 Cell F13
01/26/2007 3:41 PM 01/29/2007 12:41 PM

Between the two dates are Friday, Saturday, Sunday, and Monday or
numerically 6, 7, 1, 2 for a total of four days but really 2 days and 21
hours.

The VBA code I'm thinking of is this...

dStart = Range("E13")
dEnd = Range("F13")
Set dCount = 0
Set hCount = 0
Set mCount = 0

For Each Weekday(Date) in dStart to dEnd
Set dCount = Weekdays(Days) ***what do i do here to get the result?
Set hCount = Weekdays(Hours) ***what do i do here to get the result?
Set mCount = Weekdays(Minutes) ***what do i do here to get the
result?
MsgBox "There are " & dCount & " Days and " & hCount & " Hours and " &
mCount & " Minutes in this selection boss"


As you can see I'm a real novice and I am quite certain I'm all sorts of
wrong but I have the idea and I'm wondering how I can complete it.


Thanks In Advance,
Fred





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pulling Data off Web - Need Function Help patfergie44 Excel Worksheet Functions 9 June 22nd 06 03:27 AM
Calculating Number of days from one date to another Renz09 Excel Discussion (Misc queries) 2 May 3rd 06 10:18 AM
Number of days left in the Month? elfmajesty Excel Discussion (Misc queries) 10 March 21st 06 11:09 PM
Number of Days in the Month Beth Excel Discussion (Misc queries) 2 March 2nd 06 03:44 PM
to find number of days between 2 dates using vba code in excel sjayar Excel Discussion (Misc queries) 3 November 3rd 05 06:24 AM


All times are GMT +1. The time now is 11:13 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"