我正在与票证项目进行日期比较,如果票证关闭,它将与关闭日期进行比较。如果车票仍处于活动状态,则该年龄会一直保留到今天。即使它为true,代码也会跳过if语句。在进行比较时,我确保它们都是字符串。我尝试了很多事情,似乎找不到原因。任何帮助都是极好的。谢谢!
Dim BlankRow As Integer
Dim Created As Integer
Dim DDiff As Date
Dim Test As String
Dim Test2 As String
Dim Test3 As String
Dim TestDate2 As Date
Dim TestDate3 As Date
Dim ValHold As Integer
Dim original As String
Dim original2 As String
Dim Compare As Integer
Dim Status As Integer
Dim CellStat As String
Dim Stuff As String
Dim Rng As Range
Dim Rng2 As Range
Dim Rng3 As Range
i = 2
Do While i < BlankRow
Set Rng = ActiveSheet.UsedRange.Find("Created", , xlValues, xlWhole)
Set Rng2 = ActiveSheet.UsedRange.Find("Updated", , xlValues, xlWhole)
Set Rng3 = ActiveSheet.UsedRange.Find("Status")
Created = Rng.Column
Compare = Rng2.Column
Status = Rng3.Column
original = cells(i, Created)
Test = cells(i, Created)
Test2 = cells(i, Compare)
TestDate = CDate(Test)
TestDate2 = CDate(Test2)
cells(i, Created) = TestDate
cells(i, Compare) = TestDate2
CellStat = cells(i, Status)
Stuff = "Closed "
If Len(CellStat) = Len(Stuff) Then
DDiff = cells(i, Compare) - cells(i, Created)
Days = (Int(DDiff))
ValHold = Days
cells(i, Created) = ValHold
cells(i, Created).Interior.ColorIndex = 3
Else
DDiff = Now - cells(i, Created)
Days = (Int(DDiff))
ValHold = Days
cells(i, Created) = ValHold
End If
i = i + 1
Loop
Function fFirstBlankRow() As Long
Dim i As Long
Dim BlankRow As Long
Dim LastRow As Long
LastRow = Range("A65536").End(xlUp).Row
i = 1
Do While BlankRow < 1
If cells(i, 1).Value = "" Then
BlankRow = i
Else
i = i + 1
End If
Loop
fFirstBlankRow = BlankRow
End Function