Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() guys, i am back with one more problem.Now i got the value in terms of Hr like (1.75 for 1.45hrs) which is of number format. i have got a series of cells like this calculating the Hrs. sa A1=1.75, A2=1.50 a3=2.50 now i want these cells to be accessed in VBA and add all the cells( can do this in Excel also but i have to perform some other operatio with the sum so i have choosen to use VBA) to get the valu 5.75(a1+a2+a3) here is the code i have used for it. Code ------------------- Dim iTotHrs As Integer iTotHrs =0 For i =1 To 3 Step 1 iTotHrs = iTotHrs + CInt(ActiveWorkbook.ActiveSheet.Cells(i, 1).Value) ' | | ' v v ' integer decimal : it will be 1.50,1.75 etc Next ------------------- here comes the actual probs. is it make a difference that adding an integer with decimal value. i am getting like 2, 2 (after rouding 1.50,1.75) which i am no interested. how can i solve this. thanks & regards, mahes -- itsmahesh ----------------------------------------------------------------------- itsmaheshp's Profile: http://www.excelforum.com/member.php...fo&userid=1585 View this thread: http://www.excelforum.com/showthread.php?threadid=27689 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() why are you using CInt. Don't use that -- mangesh_yada ----------------------------------------------------------------------- mangesh_yadav's Profile: http://www.excelforum.com/member.php...fo&userid=1047 View this thread: http://www.excelforum.com/showthread.php?threadid=27689 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Also declare your variable iTotHrs as Double Not Integer.
You van use worksheet functiosn as well Dim iTotHrs As Double iTotHrs = WorksheetFunction.Sum(Range("A1:A3")) -- HTH RP (remove nothere from the email address if mailing direct) "mangesh_yadav" wrote in message ... why are you using CInt. Don't use that. -- mangesh_yadav ------------------------------------------------------------------------ mangesh_yadav's Profile: http://www.excelforum.com/member.php...o&userid=10470 View this thread: http://www.excelforum.com/showthread...hreadid=276891 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Oops I missed on that one too. You need to declare the variable a double as well. Thanks Bob -- mangesh_yada ----------------------------------------------------------------------- mangesh_yadav's Profile: http://www.excelforum.com/member.php...fo&userid=1047 View this thread: http://www.excelforum.com/showthread.php?threadid=27689 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
My pleasure.
Bob "mangesh_yadav" wrote in message ... Oops I missed on that one too. You need to declare the variable as double as well. Thanks Bob. -- mangesh_yadav ------------------------------------------------------------------------ mangesh_yadav's Profile: http://www.excelforum.com/member.php...o&userid=10470 View this thread: http://www.excelforum.com/showthread...hreadid=276891 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Time calculations for Scheduled vs Actual Employee Time and Wages | Excel Discussion (Misc queries) | |||
Time calculations for Scheduled Time vs. Actual Time Worked | Excel Discussion (Misc queries) | |||
Time calculations for Scheduled vs Actual Employee Time and Wages | Excel Discussion (Misc queries) | |||
Time difference calculations, daylight savings time, Excel | Excel Discussion (Misc queries) | |||
convert time imported as text to time format for calculations | Excel Worksheet Functions |