那就用这个吧,加上
If Int(rg.Value) = rg.Value And rg.Value >= 1 And rg.Value <= n Then
rg.Value = DateSerial(Year(Date), Month(Date) - 1, rg.Value)
rg.NumberFormatLocal = "yyyy-m-d"
ElseIf rg.Value > Date - Day(Date) - n And rg.Value < Date - Day(Date) Then
rg.NumberFormatLocal = "yyyy-m-d"
Else
rg.ClearContents
End If
那就用这个吧,加上
If Int(rg.Value) = rg.Value And rg.Value >= 1 And rg.Value <= n Then
rg.Value = DateSerial(Year(Date), Month(Date) - 1, rg.Value)
rg.NumberFormatLocal = "yyyy-m-d"
ElseIf rg.Value > Date - Day(Date) - n And rg.Value < Date - Day(Date) Then
rg.NumberFormatLocal = "yyyy-m-d"
Else
rg.ClearContents
End If