我比较两列(D和E)中的两个日期。 D列中的日期是源日期,E列中的日期是项目的开始日期。
我计算两个日期的差异为星期,并将结果粘贴在F列并相应地突出显示。
我有4个案例:
我已经实现了树案例。
我试着把它作为Null,但是,我无法弄清楚,为什么这个案例4不起作用。
function isSquare(n) {
return n > 0 && Math.sqrt(n) % 1 === 0;
};
//Equation modified from http://www.geeksforgeeks.org/check-number-fibonacci-number/
function isFibonacci(numberToCheck)
{
// numberToCheck is Fibinacci if one of 5*n*n + 4 or 5*n*n - 4 or both
// is a perferct square
return isPerfectSquare(5*numberToCheck*numberToCheck + 4) ||
isPerfectSquare(5*numberToCheck*numberToCheck - 4);
}
请帮我解决这个问题 问候, Mikz
答案 0 :(得分:0)
检查:
Sub dateCompare()
zLastRow = Range("D" & Rows.Count).End(xlUp).Row 'last data row
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
For r = 2 To zLastRow
If IsEmpty(Cells(r, "E").Value) Then 'check if column is empty
zColour = xlNone
zText = " check dates"
else
zWeeks = (Cells(r, "E") - Cells(r, "D")) / 7 'date difference in weeks
Select Case zWeeks
Case Is > 4 'later than 4 weeks
zColour = vbRed
zText = "Project delayed " & Int(zWeeks) & " weeks"
Case 2 To 4 'between 2 and 4 weeks
zColour = vbYellow
zText = "Project ongoing"
Case Is < 2 'less than 2 weeks
zColour = vbGreen
zText = "Project On-Time"
End Select
End if
Cells(r, "D").Interior.Color = zColour 'set cell background colour
Cells(r, "F") = zText 'set project status
Next
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
End Sub