Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Time calculations in VBA


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Time calculations in VBA


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Time calculations in VBA

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Time calculations in VBA


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Time calculations in VBA

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
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 calculations for Scheduled vs Actual Employee Time and Wages The Caterer Excel Discussion (Misc queries) 4 November 29th 09 11:51 PM
Time calculations for Scheduled Time vs. Actual Time Worked The Caterer Excel Discussion (Misc queries) 1 November 29th 09 08:08 AM
Time calculations for Scheduled vs Actual Employee Time and Wages The Caterer Excel Discussion (Misc queries) 2 November 29th 09 12:20 AM
Time difference calculations, daylight savings time, Excel Tim Excel Discussion (Misc queries) 1 December 28th 06 04:18 PM
convert time imported as text to time format for calculations batfish Excel Worksheet Functions 3 October 27th 05 11:24 PM


All times are GMT +1. The time now is 07:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"