Find time difference and display it in hours

Joined
Jun 20, 2015
Messages
1
Reaction score
0
Hi can anyone help me to add the necessary codes that results in displaying the time difference in hours?
Function FnCDate()
Dim strDiffr
Dim intTime
Dim strTime

intTime = CDate(Left(ActiveWorkbook.Sheets("Sheet4").Cells(y, 8), 11)) 'This is my column which has timings in AM nd PM format

strTime = TimeValue(Now) 'Here is my current time
strDiffr = CDate(strTime) - CDate(intTime) 'calculating the time difference- even if my intTime and strTime are in same format(Both AM or Both PM) for eg intTime= 3:15:00 AM strTime=4:14:00AM It results in 12:59:00 AM, but i want to display this in hours .


MsgBox CDate(intDate)

MsgBox CDate(strTime)

MsgBox CDate(strDiffr) 'whatever the result is i want it to be shown in hours

End Function
Plz help me out in this......!!:confused:
 
Joined
Jun 29, 2015
Messages
4
Reaction score
2
change the number formatting of the result, use the one hh:mm:ss format that can be found on custom format. I don't know if it is applicable in MsgBox Function, maybe you can target a cell that has this result to show up in the msgbox. hope it help, I'm not good in VBA, i'm newbie. cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top