- ©«¤l
- 1446
- ¥DÃD
- 40
- ºëµØ
- 0
- ¿n¤À
- 1470
- ÂI¦W
- 0
- §@·~¨t²Î
- Windows 7
- ³nÅ骩¥»
- Excel 2010 & 2016
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW
- µù¥U®É¶¡
- 2020-7-15
- ³Ì«áµn¿ý
- 2024-10-21
|
¦^´_ 9# gaishutsusuru
ÁÂÁ½׾Â,ÁÂÁ«e½ú¦^´_
«á¾Ç¤µ¤Ñ½Æ²ß¤è®×,¤ß±oµù¸Ñ¦p¤U,½Ð«e½ú°Ñ¦Ò,½Ð¦U¦ì«e½ú«ü±Ð
Option Explicit
Function GetSerial(ST$)
'¡ô¦Ûq¨ç¼ÆGetSerial() «Å§iÅܼÆ:¿é¤J¨ç¼Æªº STÅܼƬO ¦r¦ê
Dim Brr, X, Q, Z$, K$, V0$, V1$, T0$, T1$, i&, M%, Y%
'¡ô«Å§iÅܼÆ:(Z,K,V0,V1,T0,T1)¬O¦r¦êÅܼÆ,i¬Oªø¾ã¼ÆÅܼÆ,
'(Y,M)¬Oµu¾ã¼ÆÅܼÆ,(Brr,X,Q)¬O³q¥Î«¬ÅܼÆ
Dim D As Date, P As Date, P1 As Date
'¡ô(D,P,P1)¬O¤é´ÁÅܼÆ
Brr = Range([A1], Cells(Rows.Count, 1).End(3))
'¡ô¥OBrr³o³q¥Î«¬ÅܼƬO¤Gºû°}¦C,¥H[A1]¨ìAÄæ³Ì«á¤@Ó¦³¤º®eÀx¦s®æȱa¤J
T0 = ST: V0 = Mid(T0, InStr(T0, "_") + 1)
'¡ô¥OT0³o¦r¦êÅܼƬO ¨Ï¥ÎªÌ¿é¤J¨ç¼Æ¸ÌªºÀx¦s®æÈ,
'¥OV0³o¦r¦êÅܼƬO T0Åܼƨú©³½u¦r¤¸(¤£§t)«áªº©Ò¦³¦r¤¸²Õ¦¨ªº·s¦r¦ê
Y = Left(Val(T0), 4): M = Val(Right(Val(T0), 2))
'¡ô¥OY³oµu¾ã¼Æ¬O T0ÅܼÆÂà¾ã¼Æ¼ÆÈ«á¨ú¥ª°¼4¦r¤¸ªº¼ÆÈ,
'¡ô¥OM³oµu¾ã¼Æ¬O T0ÅܼÆÂà¾ã¼Æ¼ÆÈ«á¨ú¥k°¼2¦r¤¸ªº¼ÆÈ
D = CDate(Y & "/" & M & "/01")
'¡ô¥OD³o¤é´ÁÅܼƬO YÅܼƳs±µ"/",¦A³s±µMÅܼÆ,³Ì«á³s±µ"/01"²Õ¦¨ªº¤é´Á
For i = 1 To UBound(Brr)
'¡ô³]¶¶°j°é!i±q1¨ì Brr°}¦CÁa¦V³Ì¤j¯Á¤Þ¦C¸¹
T1 = Brr(i, 1): V1 = Mid(T1, InStr(T1, "_") + 1)
'¡ô¥OT1³o¦r¦êÅܼƬO i°j°é¦C²Ä1ÄæBrr°}¦CÈ,
'¥OV1³o¦r¦êÅܼƬO T1Åܼƨú©³½u¦r¤¸(¤£§t)«áªº©Ò¦³¦r¤¸²Õ¦¨ªº·s¦r¦ê
Y = Left(Val(T1), 4): M = Val(Right(Val(T1), 2))
'¡ô¥OY³oµu¾ã¼Æ¬O T1ÅܼÆÂà¾ã¼Æ¼ÆÈ«á¨ú¥ª°¼4¦r¤¸ªº¼ÆÈ,
'¡ô¥OM³oµu¾ã¼Æ¬O T1ÅܼÆÂà¾ã¼Æ¼ÆÈ«á¨ú¥k°¼2¦r¤¸ªº¼ÆÈ
Y = Y + M \ 12: M = M Mod 12 + 1
'¡ô¥OYÅܼƬO ¦Û¨+(MÅܼư£12ªº¾ã¼Æ°Ó)
'¥OMÅܼƬO ¦Û¨°£12«áªº¾l¼Æ,¦A+1
P = CDate(Y & "/" & M & "/01") - 1
'¡ô¥OP³o¤é´ÁÅܼƬO YÅܼƳs±µ"/",¦A³s±µMÅܼÆ,
'³Ì«á³s±µ"/01"²Õ¦¨ªº«e¤@¤Ñ¤é´Á(¨D«e¤@Ӥ몺³Ì«á¤@¤Ñ)
If (T0 = T1) + (V0 <> V1) + (P > D) Then GoTo i01
'¡ô¦pªG³o¤TÓ±ø¥óªº¨ä¤¤¤@Ó¤£¬O0!´N¸õ¨ì i01¦ì¸mÄ~Äò°õ¦æ
If P1 - Date < P - Date Then
'¡ô¦pªGP1ÅܼÆ-¤µ¤Ñ¤é´Á ¤p©ó PÅܼÆ-¤µ¤Ñ¤é´Á?
P1 = P: Z = Format(P1, "YYYYMM") & "_" & V0
'¡ô¥OP1ÅܼƸËPÅܼÆ,¥OZ³o¦r¦êÅܼƬO P1ÅܼÆÂà4½X¦~2½X¤ë,
'¦A³s±µ©³½u¦r¤¸,³Ì«á³s±µV0Åܼƪº·s¦r¦ê
End If
i01: Next
GetSerial = IIf(Z <> "", Z, "µL")
'¡ô¦^¶Çȵ¹¦Ûq¨ç¼Æ:
'¦pªGZÅܼƤ£¬OªÅ¦r¤¸´N¦^¶ÇZÅܼÆ,§_«h¦^¶Ç"µL"¦r¤¸
Erase Brr
'¡ô¥OÄÀ©ñÅܼÆ
End Function |
|