Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
转换双精度时使用EXCEL VBA<;0到时间获取#值_Excel_Vba - Fatal编程技术网

转换双精度时使用EXCEL VBA<;0到时间获取#值

转换双精度时使用EXCEL VBA<;0到时间获取#值,excel,vba,Excel,Vba,我有这个工作簿,有两个工作表,每个工作表包含一列时间,我需要同步时间-通过每个时间列中的第一个单元格,我通过查找时间间隔并从第二张工作表中添加/减去时间量来同步时间。看起来像这样: Dim somethingz As Double Dim SanTime As Date, PhTime As Date SanTime = Worksheets("Sanity").Cells(2, "B").Value PhTime = Worksheets("PH").Cells(2, "B").Value

我有这个工作簿,有两个工作表,每个工作表包含一列时间,我需要同步时间-通过每个时间列中的第一个单元格,我通过查找时间间隔并从第二张工作表中添加/减去时间量来同步时间。看起来像这样:

Dim somethingz As Double
Dim SanTime As Date, PhTime As Date

SanTime = Worksheets("Sanity").Cells(2, "B").Value
PhTime = Worksheets("PH").Cells(2, "B").Value

For i = 2 To phRowN

            somethingz = Worksheets("PH").Cells(i, "B").Value - dblDuration
            Worksheets("PH").Cells(i, "B").Value = Application.Text(somethingz, "[hh]:mm:ss")
       Next i
    Else
        dblDuration = PhTime - SanTime
        For i = 2 To phRowN

            somethingz = Worksheets("PH").Cells(i, "B").Value - dblDuration

            If (somethingz < 0) Then
                somethingz = something + twentyfour
            End If

            Worksheets("PH").Cells(i, "B").Value = Application.Text(somethingz, "[hh]:mm:ss")

       Next i
    End If
If dblDuration < Worksheets("PH").Cells(i, "B").Value Then
    dblDuration = dblDuration +1
End if
somethingz = Worksheets("PH").Cells(i, "B").Value - dblDuration
Worksheets("PH").Cells(i, "B").Value = Application.Text(somethingz, "[hh]:mm:ss")
Dim somethingz为双精度
Dim SanTime作为日期,PhTime作为日期
SanTime=工作表(“健全”).单元格(2,“B”).值
PhTime=工作表(“PH”).单元格(2,“B”).值
对于i=2到phRowN
somethingz=工作表(“PH”)。单元格(i,“B”)。值-dblDuration
工作表(“PH”).单元格(i,“B”).值=应用程序.Text(somethingz,[hh]:mm:ss”)
接下来我
其他的
dblDuration=PhTime-SanTime
对于i=2到phRowN
somethingz=工作表(“PH”)。单元格(i,“B”)。值-dblDuration
如果(某物z<0),则
somethingz=某物+24
如果结束
工作表(“PH”).单元格(i,“B”).值=应用程序.Text(somethingz,[hh]:mm:ss”)
接下来我
如果结束

现在,在我得到
somethingz之前,这非常有效,请尝试以下内容:

Dim somethingz As Double
Dim SanTime As Date, PhTime As Date

SanTime = Worksheets("Sanity").Cells(2, "B").Value
PhTime = Worksheets("PH").Cells(2, "B").Value

For i = 2 To phRowN

            somethingz = Worksheets("PH").Cells(i, "B").Value - dblDuration
            Worksheets("PH").Cells(i, "B").Value = Application.Text(somethingz, "[hh]:mm:ss")
       Next i
    Else
        dblDuration = PhTime - SanTime
        For i = 2 To phRowN

            somethingz = Worksheets("PH").Cells(i, "B").Value - dblDuration

            If (somethingz < 0) Then
                somethingz = something + twentyfour
            End If

            Worksheets("PH").Cells(i, "B").Value = Application.Text(somethingz, "[hh]:mm:ss")

       Next i
    End If
If dblDuration < Worksheets("PH").Cells(i, "B").Value Then
    dblDuration = dblDuration +1
End if
somethingz = Worksheets("PH").Cells(i, "B").Value - dblDuration
Worksheets("PH").Cells(i, "B").Value = Application.Text(somethingz, "[hh]:mm:ss")
如果dblDuration<工作表(“PH”).单元格(i,“B”).值,则
dblDuration=dblDuration+1
如果结束
somethingz=工作表(“PH”)。单元格(i,“B”)。值-dblDuration
工作表(“PH”).单元格(i,“B”).值=应用程序.Text(somethingz,[hh]:mm:ss”)

为了回答者和未来读者的利益:如果答案解决了您的问题,请单击旁边的大复选标记接受它;如果您觉得它至少有帮助,请单击向上箭头图标向上投票。为了对你接受的答案表示额外的感谢,你可以另外投票。