下面是我公司的工厂日历的模块代码:它是有规律的每一个P几都是开始日期和结束日期减
请问有没有办法写一段万年历是的代码,免去每次都需要更改里面的日期的代码。
谢谢
Fisher2010年工厂日历
Function GetP(a As Date) As String
Dim Re As String
If a >= CDate("2009-10-1") And a <= CDate("2009-10-23") Then
Re = "2010_P1"
ElseIf a >= CDate("2009-10-24") And a <= CDate("2009-11-20") Then
Re = "2010_P2"
ElseIf a >= CDate("2009-11-21") And a <= CDate("2009-12-25") Then
Re = "2010_P3"
ElseIf a >= CDate("2009-12-26") And a <= CDate("2010-01-22") Then
Re = "2010_P4"
ElseIf a >= CDate("2010-01-23") And a <= CDate("2010-02-19") Then
Re = "2010_P5"
ElseIf a >= CDate("2010-02-20") And a <= CDate("2010-03-26") Then
Re = "2010_P6"
ElseIf a >= CDate("2010-03-27") And a <= CDate("2010-04-23") Then
Re = "2010_P7"
ElseIf a >= CDate("2010-04-24") And a <= CDate("2010-05-21") Then
Re = "2010_P8"
ElseIf a >= CDate("2010-05-22") And a <= CDate("2010-06-25") Then
Re = "2010_P9"
ElseIf a >= CDate("2010-06-26") And a <= CDate("2010-07-23") Then
Re = "2010_P10"
ElseIf a >= CDate("2010-07-24") And a <= CDate("2010-08-20") Then
Re = "2010_P11"
ElseIf a >= CDate("2010-08-21") And a <= CDate("2010-09-30") Then
Re = "2010_P12"
Else
End If
GetP = Re
End Function
Fisher2011年工厂日历
Function GetP(A As Date) As String
Dim Re As String
If A >= CDate("2010-10-1") And A <= CDate("2010-10-22") Then
Re = "2011_P1"
ElseIf A >= CDate("2010-10-23") And A <= CDate("2010-11-19") Then
Re = "2011_P2"
ElseIf A >= CDate("2010-11-20") And A <= CDate("2010-12-24") Then
Re = "2011_P3"
ElseIf A >= CDate("2010-12-25") And A <= CDate("2011-01-21") Then
Re = "2011_P4"
ElseIf A >= CDate("2011-01-22") And A <= CDate("2011-02-18") Then
Re = "2011_P5"
ElseIf A >= CDate("2011-02-19") And A <= CDate("2011-03-25") Then
Re = "2011_P6"
ElseIf A >= CDate("2011-03-26") And A <= CDate("2011-04-22") Then
Re = "2011_P7"
ElseIf A >= CDate("2011-04-23") And A <= CDate("2011-05-20") Then
Re = "2011_P8"
ElseIf A >= CDate("2011-05-21") And A <= CDate("2011-06-24") Then
Re = "2011_P9"
ElseIf A >= CDate("2011-06-25") And A <= CDate("2011-07-22") Then
Re = "2011_P10"
ElseIf A >= CDate("2011-07-23") And A <= CDate("2011-08-19") Then
Re = "2011_P11"
ElseIf A >= CDate("2011-08-20") And A <= CDate("2011-09-30") Then
Re = "2011_P12"
Else
End If
GetP = Re
End Function
Fisher2012年工厂日历
Function GetP(A As Date) As String
Dim Re As String
If A >= CDate("2011-10-1") And A <= CDate("2011-10-21") Then
Re = "2012_P1"
ElseIf A >= CDate("2011-10-22") And A <= CDate("2011-11-18") Then
Re = "2012_P2"
ElseIf A >= CDate("2011-11-19") And A <= CDate("2011-12-23") Then
Re = "2012_P3"
ElseIf A >= CDate("2010-12-24") And A <= CDate("2012-01-20") Then
Re = "2012_P4"
ElseIf A >= CDate("2012-01-21") And A <= CDate("2012-02-17") Then
Re = "2012_P5"
ElseIf A >= CDate("2012-02-18") And A <= CDate("2012-03-24") Then
Re = "2012_P6"
ElseIf A >= CDate("2012-03-25") And A <= CDate("2012-04-21") Then
Re = "2012_P7"
ElseIf A >= CDate("2012-04-22") And A <= CDate("2012-05-19") Then
Re = "2012_P8"
ElseIf A >= CDate("2012-05-20") And A <= CDate("2012-06-23") Then
Re = "2012_P9"
ElseIf A >= CDate("2012-06-24") And A <= CDate("2012-07-21") Then
Re = "2012_P10"
ElseIf A >= CDate("2012-07-22") And A <= CDate("2012-08-18") Then
Re = "2012_P11"
ElseIf A >= CDate("2012-08-19") And A <= CDate("2012-09-30") Then
Re = "2012_P12"
Else
End If