Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

[b]Lunch Break Duration[/b]

Status
Not open for further replies.

trystanhuwwilliams1

Programmer
Jan 7, 2003
44
0
0
GB
Good Afternoon,

Two columns in my flexi time worksheet represent the time that I began and finished my lunch.

By deducting the cell in the second column from the cell in the first, I get the duration of my lunch break for that day.

How can I (in code) calculate the average lunch time duration for a full year?

I don't want to store any values in the worksheet, only in code.

My aim is to be able to scan worksheets for average values, such as start time, finish time and lunch duration.




Thank you,

T
 
I would set up 2 variables. One to add each lunch duation. The other as a counter.

Loop through your range adding the times together and incrementing your counter by one. When done, divide the total by the counter. That should give you an average.

 
something like this
Dim intCounter As Integer
Dim dblTimeCount As Double
Range("A16000").Select
Selection.End(xlUp).Select
intCounter = ActiveCell.Row
dblTimeCount = 0
For IntI = 1 To intCounter

dblTimeCount = dblTimeCount + (Cells(IntI, 2).Value - Cells(IntI, 1).Value)

Next IntI
MsgBox dblTimeCount / intCounter
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top