增量日期变量变量33

时间:2016-06-02 15:04:52

标签: excel vba excel-vba

我想这样做:

dim inc as long , J as date 

inc = 8
j = 2 h / inc '2:00 / 8 

msgbox j      'j = 00:15 

range("A1").value = j ' = 00: 15 
你可以帮我吗

1 个答案:

答案 0 :(得分:0)

我相信这就是你要找的东西:

Public Sub tmpTest()

Dim inc As Long, J As Date

inc = 8
J = "02:00:00"
'or use the following line
'J = TimeSerial(2, 0, 0)

MsgBox CDate(CDbl(J) / 8)      'j = 00:15

Range("A1").Value = CDate(CDbl(J) / 8) ' = 00: 15

End Sub