第2个回答 2010-09-28
按alt+f11,在左边双击你的工作表,粘贴以下代码到右边
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 Then
If IsDate(Target) Then
Cells(Target.Row, 1) = Format(Target, "yyyy-mm-dd")
Cells(Target.Row, 2) = Format(Now, "yyyy-mm-dd")
newdate = Year(Date) & "-" & Month(Target) & "-" & Day(Target)
Cells(Target.Row, 3) = DateDiff("d", newdate, Date)
If Cells(Target.Row, 3) < 0 Then
Exit Sub
End If
If Cells(Target.Row, 3) <= 10 Then
Cells(Target.Row, 3).Select
With Selection.Interior
.ColorIndex = 3
End With
End If
End If
End If
End Sub
不需要公示了,直接在A列输入日期就行了!一切自动计算!
第3个回答 2010-09-28
B1输入“=TODAY()”。C1输入“=IF((365-(B1-A1))<10,"一年期快到",365-B1+A1)”。那个英文输入法引号下的"一年期快到",你可以随意改为你想要的。如果要变成红色,需要VB编程或者如各位所说建立条件格式,也很简单。