• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Select TimeValue from cell

Cammandk

Member
I have a cell that shows the minutes I require (although formatted hh:mm:ss - still seems to
include date)

Sheet6.Range("TimeInterval")

How can I use this in the code below.

Code:
dTime = Now + TimeValue("00:05:00")

Thanks
DK
 
To get just the time portion, XL formula would be:
=MOD(A2,1)
which gives the remainder after dividing by 1 (since dates are integers). VB, unfortunately, decided that Mod method should round numbers, which is very annoying. This example should help you out:
Code:
Sub Example()
'Define 1 variable as a double (with decimals), 1 as integer only
Dim timeDuration As Double, y As Long
Dim dTime As Date

timeDuration = Range("TimeInterval").Value

'This is same as =TRUNC(A2)
'The Mod method in VB automatically rounds, otherwise we would use that
y = timeDuration

'Subtract integer portion off, to get only time
timeDuration = timeDuration - y

dTime = Now + timeDuration

End Sub
 
Hi Luke

Once again thank you for solution - it's working nicely.

I posted an earlier thread 25th May "Add new cell value to list in another sheet"

Would you have any thoughts on this - if you can?

DK
 
Back
Top