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

[µo°Ý] ½Ð°Ý¦p¦ó¼¶¼g®É¶¡»¼´îªºµ{¦¡½X?

[µo°Ý] ½Ð°Ý¦p¦ó¼¶¼g®É¶¡»¼´îªºµ{¦¡½X?

¹w­p·|¼g¨ì30¡A¼g¨ì¤F7µo²{µ{¦¡½X¦nªø¡A§Ú³o¸Ì¤]·|¥hª¦¤å¬Ý¬Ý¦p¦ó¼¶¼g¡AÁÂÁ«e½ú¡C
  1.     N0 = Now
  2.     yTD0 = Format(N0, "yyyy")
  3.     mTD0 = Format(N0, "m")
  4.     dTD0 = Format(N0, "dd")
  5.     CBN0 = yTD0 & "/" & mTD0 & "/" & dTD0
  6.    
  7.     N1 = Now - 1
  8.     yTD1 = Format(N1, "yyyy")
  9.     mTD1 = Format(N1, "m")
  10.     dTD1 = Format(N1, "dd")
  11.     CBN1 = yTD1 & "/" & mTD1 & "/" & dTD1
  12.    
  13.     N2 = Now - 2
  14.     yTD2 = Format(N2, "yyyy")
  15.     mTD2 = Format(N2, "m")
  16.     dTD2 = Format(N2, "dd")
  17.     CBN2 = yTD2 & "/" & mTD2 & "/" & dTD2
  18.    
  19.     N3 = Now - 3
  20.     yTD3 = Format(N3, "yyyy")
  21.     mTD3 = Format(N3, "m")
  22.     dTD3 = Format(N3, "dd")
  23.     CBN3 = yTD3 & "/" & mTD3 & "/" & dTD3
  24.    
  25.     N4 = Now - 4
  26.     yTD4 = Format(N4, "yyyy")
  27.     mTD4 = Format(N4, "m")
  28.     dTD4 = Format(N4, "dd")
  29.     CBN4 = yTD4 & "/" & mTD4 & "/" & dTD4
  30.    
  31.     N5 = Now - 5
  32.     yTD5 = Format(N5, "yyyy")
  33.     mTD5 = Format(N5, "m")
  34.     dTD5 = Format(N5, "dd")
  35.     CBN5 = yTD5 & "/" & mTD5 & "/" & dTD5
  36.    
  37.     N6 = Now - 6
  38.     yTD6 = Format(N6, "yyyy")
  39.     mTD6 = Format(N6, "m")
  40.     dTD6 = Format(N6, "dd")
  41.     CBN6 = yTD6 & "/" & mTD6 & "/" & dTD6
  42.    
  43.     N7 = Now - 7
  44.     yTD7 = Format(N7, "yyyy")
  45.     mTD7 = Format(N7, "m")
  46.     dTD7 = Format(N7, "dd")
  47.     CBN7 = yTD7 & "/" & mTD7 & "/" & dTD7
  48.    
  49.     With Sheets("¨t²ÎÀÉ").ComboBox1
  50.         .AddItem CBN0
  51.         .AddItem CBN1
  52.         .AddItem CBN2
  53.         .AddItem CBN3
  54.         .AddItem CBN4
  55.         .AddItem CBN5
  56.         .AddItem CBN6
  57.         .AddItem CBN7
  58.     End With
½Æ»s¥N½X

¥»©«³Ì«á¥Ñ singo1232001 ©ó 2022-8-17 02:56 ½s¿è

¦^´_ 1# av8d


Sub test2()
Sheets("¨t²ÎÀÉ").ComboBox1.Clear
For i = 1 To 7
Sheets("¨t²ÎÀÉ").ComboBox1.AddItem Date - i
Next
End Sub



¦pªG­n¦³0

Sub test3()
Sheets("¨t²ÎÀÉ").ComboBox1.Clear
For i = 1 To 7
Sheets("¨t²ÎÀÉ").ComboBox1.AddItem Format(Date - i, "yyyy/mm/dd")
Next
End Sub

TOP

¥»©«³Ì«á¥Ñ av8d ©ó 2022-8-17 14:11 ½s¿è

¦^´_ 2# singo1232001


·PÁ±z©âªÅ¸Ñµª¡A§Ú­×§ï¤F±ø¥ó¡A¤]¨S°ÝÃD¡A¦ý¬O­×§ï¨ìÂù±ø¥ó¡A«h¥X²{°ÝÃD¡A¤£ª¾°ÝÃD¦b­þ¡C

For i = 1 To 7
    If WeekdayName(Weekday(Date - i)) <> "¬P´Á¤»" Then
        Sheets("¨t²ÎÀÉ").ComboBox1.AddItem Date - i
    End If
Next

¥H¤W³æ¤@±ø¥ó¬P´Á¤»¬Ù²¤¡A«h¨S°ÝÃD¡A¦ý¬O¥H¤UÂù±ø¥ó¡A«h¥X²{¤FÂù±ø¥ó³£¤£·|³Q¬Ù²¤ªº°ÝÃD¡C

For i = 1 To 7
    If WeekdayName(Weekday(Date - i)) <> "¬P´Á¤»" Or WeekdayName(Weekday(Date - i)) <> "¬P´Á¤é" Then
        Sheets("¨t²ÎÀÉ").ComboBox1.AddItem Date - i
    End If
Next


°ÝÃD¤G¡B
·í§ï¼g¬°¥H¤µ¤Ñ¬°¥D¡A«e«á7¤Ñ¡AµM«á¥¿±`¶¶§Ç±Æ¦C¡A¤]·|¥X²{¨S¦³¥¿±`±Æ§Çªº°ÝÃD¡A¥Ø«e¦b¦Ò¼{¬O§_¼g¦bÀx¦s®æ¤¤¡AµM«á¦A¶¶¦VŪ¨ú¤@¦¸¡C

For i = 1 To 7
    Sheets("¨t²ÎÀÉ").ComboBox1.AddItem Date + i
Next
For i = 1 To 7
    Sheets("¨t²ÎÀÉ").ComboBox1.AddItem Date - i
Next

TOP

¦^´_ 2# singo1232001

°ÝÃD¤@¤w¸Ñ¶}¡A³Ñ¤U°ÝÃD¤G¡A¤Q¤À·PÁ¡I

°ÝÃD¤G¡B
·í§ï¼g¬°¥H¤µ¤Ñ¬°¥D¡A«e«á7¤Ñ¡AµM«á¥¿±`¶¶§Ç±Æ¦C¡A¤]·|¥X²{¨S¦³¥¿±`±Æ§Çªº°ÝÃD¡A¥Ø«e¦b¦Ò¼{¬O§_¼g¦bÀx¦s®æ¤¤¡AµM«á¦A¶¶¦VŪ¨ú¤@¦¸¡C

For i = 1 To 7
    Sheets("¨t²ÎÀÉ").ComboBox1.AddItem Date + i
Next
For i = 1 To 7
    Sheets("¨t²ÎÀÉ").ComboBox1.AddItem Date - i
Next

TOP

¦^´_ 2# singo1232001


    ¥þ³¡°ÝÃD¤w¸Ñ¶}¡A¸U¤À·PÁ«e½úªº´£Äâ¡A¨ü¯q¨}¦h¡A¸U¤À·PÁ¡I

¥H¤U¬O°ÝÃD¤Gªº¸Ñªk~

For i = 7 To 1 Step -1
    If WeekdayName(Weekday(Date - i)) = "¬P´Á¤G" Or WeekdayName(Weekday(Date - i)) = "¬P´Á¤­" Then
        Sheets("¨t²ÎÀÉ").ComboBox1.AddItem Date - i
    End If
Next
For i = 1 To 7
    If WeekdayName(Weekday(Date + i)) = "¬P´Á¤G" Or WeekdayName(Weekday(Date + i)) = "¬P´Á¤­" Then
        Sheets("¨t²ÎÀÉ").ComboBox1.AddItem Date + i
    End If
Next

TOP

¥»©«³Ì«á¥Ñ singo1232001 ©ó 2022-8-17 22:45 ½s¿è

¦^´_ 5# av8d


Sub test()
Sheets("¨t²ÎÀÉ").ComboBox1.Clear
For i = 7 To -7 Step -1
     wdi = Weekday(Date - i, 2)
    If wdi = 2 Or wdi = 5 Then
        Sheets("¨t²ÎÀÉ").ComboBox1.AddItem Format(Date - i, "yyyy/m/d") & " " & WeekdayName(wdi, , 2)
        'Sheets("¨t²ÎÀÉ").ComboBox1.AddItem Format(Date - i, "yyyy/m/d")  '¨S¬P´Á´X
    End If
Next
End Sub

'­nª`·N·í¤é ¼²¤W¬P´Á¤G»P¬P´Á¤­ªº°ÝÃD ³oºØ¼gªk¬O·í¤é¬P´Á¤G©Î¬P´Á¤­¤]·|§ä¨ì   ¥]¬A«á­±Åã¥Ü¬P´Á´X

TOP

¦^´_ 6# singo1232001


«e½ú¦³±zªº§ï¼g¡A§Ú¶i¨B¦n¦h¡AµL½×¬O½d³ò¡B«ü©w¤é´Á³£¤j¤j´£¤É¼¶¼gªº¤è«K©Ê¡A¥H¤U¬O§Ú³Ì«á§ï¼g¥X¨Óªº¦¨ªG¡AÁÂÁ±z¡I

For i = 11 To -11 Step -1
    wdi = Weekday(Date - i, 2)
    If wdi >= 1 And wdi <= 5 Then
        Sheets("¨t²ÎÀÉ").ComboBox1.AddItem Format(Date - i, "yyyy/m/d") & " " & WeekdayName(wdi, 1, 2)
        'Sheets("¨t²ÎÀÉ").ComboBox1.AddItem Format(Date - i, "yyyy/m/d")  '¨S¬P´Á´X
    End If
Next
wd = Weekday(Date, 2)
wd4 = Weekday(Date + 4, 2)
wd3 = Weekday(Date + 3, 2)
wd2 = Weekday(Date + 2, 2)
wd1 = Weekday(Date + 1, 2)
If wd = 1 Or wd = 5 Then Sheets("¨t²ÎÀÉ").ComboBox1 = Format(Date + 4, "yyyy/m/d") & " " & WeekdayName(wd4, 1, 2)
If wd = 2 Or wd = 6 Then Sheets("¨t²ÎÀÉ").ComboBox1 = Format(Date + 3, "yyyy/m/d") & " " & WeekdayName(wd3, 1, 2)
If wd = 3 Then Sheets("¨t²ÎÀÉ").ComboBox1 = Format(Date + 2, "yyyy/m/d") & " " & WeekdayName(wd2, 1, 2)
If wd = 4 Then Sheets("¨t²ÎÀÉ").ComboBox1 = Format(Date + 1, "yyyy/m/d") & " " & WeekdayName(wd1, 1, 2)

TOP

¥»©«³Ì«á¥Ñ singo1232001 ©ó 2022-8-18 23:52 ½s¿è

¦^´_ 7# av8d


Sub test()
Set Sc = Sheets("¨t²ÎÀÉ").ComboBox1
Sc.Clear
For i = 11 To -11 Step -1
  w = Weekday(Date - i, 2)
  If w >= 1 And w <= 5 Then Sc.AddItem Format(Date - i, "yyyy/m/d") & " " & WeekdayName(w, 1, 2)
Next

Select Case Weekday(Date, 2)
Case Is = 1, 5: Sc.Text = Format(Date + 4, "yyyy/m/d") & " " & WeekdayName(Weekday(Date + 4, 2), 1, 2)
Case Is = 2, 6: Sc.Text = Format(Date + 3, "yyyy/m/d") & " " & WeekdayName(Weekday(Date + 3, 2), 1, 2)
Case Is = 3: Sc.Text = Format(Date + 2, "yyyy/m/d") & " " & WeekdayName(Weekday(Date + 2, 2), 1, 2)
Case Is = 4: Sc.Text = Format(Date + 1, "yyyy/m/d") & " " & WeekdayName(Weekday(Date + 1, 2), 1, 2)
End Select
End Sub

1.  Sheets("¨t²ÎÀÉ").ComboBox1 ¥i¥HÁY¼g¦¨§A·Q­n¨ì¦WºÙ
2.¦h±ø¥ó§PÂ_ ¥i¥H½m²ß¨Ï¥Îselect case   ·íµMif¤]¨S°ÝÃD
·|¥Îªº­ì¦]¬O ·í¦h±ø¥ó¤º³¡  ¥¼¨Ó¥X²{¦h¼h§PÂ_®É ¥i¥Hselect case + if then ·f°t ¤ñ¸û¦n¤À¿ë

­Y§¹¦¨«á ¤]¥i¥Hª½±µ¥þ³¡¨Ï¥Îwith Sheets("¨t²ÎÀÉ").ComboBox1 ªº¤è¦¡¥þ¥]°_¨Ó

TOP

        ÀR«ä¦Û¦b : ¶¢¤HµL¼Ö½ì¡A¦£¤HµL¬O«D¡C
ªð¦^¦Cªí ¤W¤@¥DÃD