ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] EXCEL ¹ï1900¦~¥H«eªº¤é´Á,¦p¦ó¬Û¥[´î

[µo°Ý] EXCEL ¹ï1900¦~¥H«eªº¤é´Á,¦p¦ó¬Û¥[´î

¥»©«³Ì«á¥Ñ dou10801 ©ó 2023-5-4 16:21 ½s¿è

½Ð±Ð¦U¦ì¥ý¶i,EXCEL ¹ï1900¦~¥H«eªº¤é´Á,¦p¦ó¬Û¥[´î.
[¨Ò]:  1850/5/20-1850/5/15=5
§ù¤p¥­

¥Î¦æ°Ê¸Ë¸mÂsÄý½×¾Â¾Ç²ß«Ü¤è«K,ÁÂÁ½׾¸gÀç¹Î¶¤
½Ð¤j®a¤@°_¤W½×¾Â¨Ó¥æ¬y

TOP

¥»©«³Ì«á¥Ñ Andy2483 ©ó 2023-5-5 08:05 ½s¿è

¦^´_ 1# dou10801


    ÁÂÁ«e½úµoªí¦¹¥DÃD
«á¾Ç¾Ç²ß¤è®×¦p¤U,½Ð«e½ú°Ñ¦Ò

°õ¦æµ²ªG:


Sub TEST_20230505_1()
MsgBox CDate("1850/5/20") - CDate("1850/5/15")
End Sub

Sub TEST_20230505_2()
Dim D1 As Date, D2 As Date
D1 = "1850/5/20": D2 = "1850/5/15"
MsgBox D1 - D2
End Sub

Sub TEST_20230505_3()
MsgBox CDate("1850/5/15") + 5
End Sub

Sub TEST_20230505_4()
MsgBox CDate("1850/5/20") - 5
End Sub
¥Î¦æ°Ê¸Ë¸mÂsÄý½×¾Â¾Ç²ß«Ü¤è«K,ÁÂÁ½׾¸gÀç¹Î¶¤
½Ð¤j®a¤@°_¤W½×¾Â¨Ó¥æ¬y

TOP

¦^´_ 3# Andy2483 ¦pªþ¥ó,·q½Ð«e½ú«ü¾É,ÁÂÁÂ.

¬Û´î¤Ñ¼Æ.rar (7.57 KB)

§ù¤p¥­

TOP

¦^´_ 4# dou10801


    ÁÂÁ«e½ú¦^´_
«á¾ÇÂǦ¹©«½m²ß°}¦C»P¤½¾ä¤é´ÁªºÀË´ú,¾Ç²ß¤è®×¦p¤U,½Ð«e½ú°Ñ¦Ò

°õ¦æ«e:


ÀË´ú¥X«D¤½¾ä¤é:


­×¥¿¤é´Á«á°õ¦æµ²ªG:



Option Explicit
Sub TEST()
Dim Brr, Crr, i&, N&, Ds As Date, Dn As Date
Brr = Range([A2], Cells(Rows.Count, "A").End(3))
ReDim Crr(1 To UBound(Brr), 1 To 2)
For i = 1 To UBound(Brr)
   If Not IsDate(Brr(i, 1)) Then Crr(i, 1) = "¡ö«D¤½¾ä¤é": N = N + 1
Next
'¡ô¥ý³]°j°éÀË´ú¤é´Á¬O§_¬°¥¿½T¤½¾ä¤é´Á
If N > 0 Then [B2].Resize(UBound(Crr), 2) = Crr: MsgBox "¸ê®Æ¿ù»~! ½Ð­×¥¿«á¦A°õ¦æ!": Exit Sub
'¡ô¦pªG¦³¿ù¥²¶·¥ý­×¥¿¿ù»~,¦A­«·s°õ¦æ
For i = 1 To UBound(Brr) - 1
   Crr(i, 1) = Brr(i + 1, 1) & "-" & Brr(i, 1)
   Ds = Brr(i + 1, 1): Dn = Brr(i, 1): Crr(i, 2) = Ds - Dn
   '¡ô¥Ñ©óÅܼƫŧi,·|¦Û°Ê±N¦r¦êÂà´«¬°¤é´Á
Next
[B2].Resize(UBound(Crr), 2) = Crr
Erase Brr, Crr
End Sub
¥Î¦æ°Ê¸Ë¸mÂsÄý½×¾Â¾Ç²ß«Ü¤è«K,ÁÂÁ½׾¸gÀç¹Î¶¤
½Ð¤j®a¤@°_¤W½×¾Â¨Ó¥æ¬y

TOP

        ÀR«ä¦Û¦b : «Î¼e¤£¦p¤ß¼e¡C
ªð¦^¦Cªí ¤W¤@¥DÃD