LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
bst bst is offline
external usenet poster
 
Posts: 19
Default performing calculations on time data

I have googled and searched this group and have not found exactly what i
am looking for. everything i have seen is for performing functions in
the worksheet and not in vba code.

i'll set up the prolbem, explain what i need, and give you what i have
come up with so far.
i have two columns with time data. i want the third column to show the
difference between the time. so if one 13:30 and the other is 14:00 i
want the 3rd column to show :30. or if one is 14:00 and the other is
13:30 i want the 3rd column to show :30
A B C
13:30 14:00 :30
14:00 13:30 :30
the all cells are formatted as general. the code snippets below are for
excel2000.

If .Cells(row, colSchedule).Value .Cells(row, colActual).Value Then
.Cells(row, colVariance).Value = .Cells(row, colSchedule).Value - _
.Cells(row, colActual).Value
Range(.Cells(row, colVariance)).NumberFormat = "hh:mm"

Else
.Cells(row, colVariance).Value = .Cells(row, colActual).Value - _
.Cells(row, colSchedule).Value
Range(.Cells(row, colVariance)).NumberFormat = "hh:mm"
End if

i have also attempted using Range(.cells(row,colSchedule).value etc....

in both attempts the comparison works fine (which boggles my mind),
however the cell assignment/mathematic operation fails with a mismatch
object error.

all cells formatted as general. i don't know if that is the problem, but
i doubt it since if i do this in the sheet, eg =B1-A1, i get no problem.

The code does not make it to the Range......NumberFormat so i have no
idea if that will work or not.

I do not think the builtin Time function(time(h,m,s) will work since i
cant seperate the information by hour.minutes. i have read how excel
stores time data, but i do not (hope not) think that applies.

what this is not is a payroll sheet or some sort of userform. based on
the if statements above some other things get processed and sorted out,
i have not included them for brevity.

there will also be a future comparison based on the result of the
calculation to the effect of if it is 30 then something happens, if it
< 30 something else happens.

i hope this is clear.

TIA
bst
 
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
Performing Calculations of data starting with Greater Than [email protected] Excel Discussion (Misc queries) 3 February 27th 09 10:31 AM
Performing calculations if a value is between A and B M. Nelson Excel Worksheet Functions 3 September 12th 08 04:35 PM
Performing calculations on only cells with data Nat Excel Worksheet Functions 3 May 7th 07 07:56 PM
Help on performing calculations on formula results AussieExcelUser Excel Worksheet Functions 3 March 14th 06 08:01 AM
Excel VBA macros and real time data calculations [email protected] Excel Programming 5 July 7th 05 04:43 PM


All times are GMT +1. The time now is 01:54 AM.

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"