Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default subtracting two date/time columns to get total time

I've got two columns that have a value of "Now" (the second column is
added later...once someone tabs to it). Once the second one is filled
out, I need to subtract the two to get the total time spent. Here is
what I attempted to do, but I really have no idea what i'm doing or how
to get this:


ActiveCell.Offset(0, 1).Formula = "=TIME(HOUR(" & ActiveCell & "),
MINUTE(" & ActiveCell & ")) - TIME(HOUR(" & ActiveCell.Offset(0, -1) &
"), MINUTE(" & ActiveCell.Offset(0, -1) & "))

Any ideas?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default subtracting two date/time columns to get total time

with Activecell
.Offset(0,1).Value = .Value - .Offset(0,-1).Value
.Numberformat = "hh:mm:ss"
End With

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Drew" wrote in message
oups.com...
I've got two columns that have a value of "Now" (the second column is
added later...once someone tabs to it). Once the second one is filled
out, I need to subtract the two to get the total time spent. Here is
what I attempted to do, but I really have no idea what i'm doing or how
to get this:


ActiveCell.Offset(0, 1).Formula = "=TIME(HOUR(" & ActiveCell & "),
MINUTE(" & ActiveCell & ")) - TIME(HOUR(" & ActiveCell.Offset(0, -1) &
"), MINUTE(" & ActiveCell.Offset(0, -1) & "))

Any ideas?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default subtracting two date/time columns to get total time

the numberformat did it. thanks for your help!

Bob Phillips wrote:
with Activecell
.Offset(0,1).Value = .Value - .Offset(0,-1).Value
.Numberformat = "hh:mm:ss"
End With

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Drew" wrote in message
oups.com...
I've got two columns that have a value of "Now" (the second column is
added later...once someone tabs to it). Once the second one is filled
out, I need to subtract the two to get the total time spent. Here is
what I attempted to do, but I really have no idea what i'm doing or how
to get this:


ActiveCell.Offset(0, 1).Formula = "=TIME(HOUR(" & ActiveCell & "),
MINUTE(" & ActiveCell & ")) - TIME(HOUR(" & ActiveCell.Offset(0, -1) &
"), MINUTE(" & ActiveCell.Offset(0, -1) & "))

Any ideas?


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
subtracting date/time Nathan Excel Worksheet Functions 8 January 29th 09 03:29 AM
Subtracting Dates to get total time work time excluding weekends Jon Ratzel[_2_] Excel Discussion (Misc queries) 2 January 31st 08 10:36 PM
Subtracting Date/Time Sapphyre Excel Discussion (Misc queries) 4 August 21st 07 01:42 AM
Subtracting Date/Time pairs Jason Adolf Excel Worksheet Functions 10 May 23rd 06 02:04 PM
subtracting columns one at a time? alnorman Excel Discussion (Misc queries) 0 September 8th 05 06:24 PM


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