Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
COG COG is offline
external usenet poster
 
Posts: 7
Default Time Calculation

Hi all, I have created a button called TIME with the
following macro attached:

Sub takeoff()
Dim stringval As String
stringval = Format(Now(), "h:mm")
ActiveCell.Value = stringval
End Sub

If I select A1 and click on this button, it will put the
current time in A1. A few minutes later I click on B1
and the TIME button and I get that cuurent time. In C1 I
have the calculation =B1-A1 which gives me the minutes
difference (ex: 10:15 10:47 result :32) What I
need is to change C1 to tenths of an hour. 1-6 minutes
= .1 hr, 7-12 minutes = .2 hr, and so forth.
Any suggestions on how I can do this?
I've tried just dividing C1 by 6 which doesn't work,
tried formating but am not sure I am picking a correct
custom format, etc.
Help please.

"JE McGimpsey" replyed:

XL stores times as fractional days, so to get hours,
multiply by 24:

C1: =CEILING((B1-A1)*24,0.1)

I replied, this didn't quite work. With A1 and B1
formatted as h:mm and the values 10:19 and 10:32
respectively, the above formula in C1 gave 7 which is
not correct. Should be .3

Further Help please!

  #2   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Time Calculation

Never Mind. "JE McGimpsey" gave
me the correct formula and it all worked after I redid my
spread sheet. These guys are great!
-----Original Message-----
Hi all, I have created a button called TIME with the
following macro attached:

Sub takeoff()
Dim stringval As String
stringval = Format(Now(), "h:mm")
ActiveCell.Value = stringval
End Sub

If I select A1 and click on this button, it will put the
current time in A1. A few minutes later I click on B1
and the TIME button and I get that cuurent time. In C1

I
have the calculation =B1-A1 which gives me the minutes
difference (ex: 10:15 10:47 result :32) What I
need is to change C1 to tenths of an hour. 1-6 minutes
= .1 hr, 7-12 minutes = .2 hr, and so forth.
Any suggestions on how I can do this?
I've tried just dividing C1 by 6 which doesn't work,
tried formating but am not sure I am picking a correct
custom format, etc.
Help please.

"JE McGimpsey" replyed:

XL stores times as fractional days, so to get hours,
multiply by 24:

C1: =CEILING((B1-A1)*24,0.1)

I replied, this didn't quite work. With A1 and B1
formatted as h:mm and the values 10:19 and 10:32
respectively, the above formula in C1 gave 7 which is
not correct. Should be .3

Further Help please!

.

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
time calculation Siteman Excel Worksheet Functions 8 February 2nd 09 11:27 PM
Stop time - start time calculation squack21 Excel Worksheet Functions 5 December 10th 07 03:20 PM
Time calculation (Subraction of Idle Time) Ajay Excel Discussion (Misc queries) 6 March 4th 07 11:54 AM
Ignoring Time in a Date Time Calculation nmp Excel Worksheet Functions 3 November 23rd 05 08:32 PM
time calculation with military time Ron Thetford Excel Worksheet Functions 8 July 29th 05 07:24 PM


All times are GMT +1. The time now is 03:55 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"