0

我一直在尝试将单元格的日期时间分配给变量,但一直出错。我的代码片段在下面,并且在timein变量处收到错误。请注意,在第一次迭代中,counterTwo = 2并且cellNextOne = 3.

        ElseIf IsEmpty(Sheet3.Cells(counterTwo, 11)) = True And IsEmpty(Sheet3.Cells(cellNextOne, `enter code here`11)) = False And IsEmpty(Sheet3.Cells(counterTwo, 13)) = False Then
        Dim Timein As Date
        Dim Timeout As Date
        
        Sheet3.Cells(counterTwo, 29).Value = cellNextOne

        Timein = Sheet3.Cells(counterTwo, 15).Value
        Timeout = Sheet3.Cells(cellNextOne, 10).Value

        Sheet3.Cells(counterTwo, 26).Value = DateDiff("n", Timein, Timeout)
        Sheet3.Cells(counterTwo, 26).Interior.ColorIndex = 45

请注意,我还尝试了以下选项:

Timein = TimeValue(Sheet3.Cells(counterTwo, 15).Value)

Timein = Sheet3.Cells(counterTwo, 15).Value2

但似乎都不起作用。关于这个问题的任何想法?

4

0 回答 0