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

[µo°Ý] Àx¦s®æ³W«h°ÝÃD

¸Õ¸ÕVBA:
  1. Sub ²©ö¾î¦¡¦~¾ä()
  2.     Dim yy As Integer, mm As Integer, dd As Integer, d2 As Integer, w As Integer
  3.     yy = 2016
  4.     [B2:AF47] = ""
  5.     [B2:AF47].Interior.ColorIndex = xlNone
  6.     For mm = 1 To 12
  7.         d2 = Day(DateSerial(yy, mm + 1, 0))
  8.         For dd = 1 To d2
  9.             Cells(mm * 4 - 1, dd + 1) = DateSerial(yy, mm, dd)
  10.             w = Weekday(Cells(mm * 4 - 1, dd + 1), vbSunday)
  11.             Cells(mm * 4 - 2, dd + 1).NumberFormatLocal = "d"
  12.             Cells(mm * 4 - 2, dd + 1).FormulaR1C1 = "=RIGHT(TEXT(R[1]C,""aaa""))"
  13.             If w = 1 Then
  14.                 Cells(mm * 4 - 2, dd + 1).Font.ColorIndex = 3
  15.             ElseIf w = 7 Then
  16.                 Cells(mm * 4 - 2, dd + 1).Font.ColorIndex = 5
  17.             Else
  18.                 Cells(mm * 4 - 2, dd + 1).Font.ColorIndex = 1
  19.             End If
  20.         Next
  21.     Next
  22. End Sub

  23. Sub º£«á¸ê°T()
  24.     Dim shA As Worksheet
  25.     Dim LstR As Integer, I As Integer, J As Integer, eDay As Integer, mNUM As Integer
  26.     Dim Rng As Range, SD As Range, ED As Range, Scel As Range, Ecel As Range
  27.     Set shA = Sheets("A")
  28.     Set Rng = [B3:AF47]
  29.     Rng.Interior.ColorIndex = xlNone
  30.     LstR = shA.[M4].End(xlDown).Row
  31.     For I = 4 To LstR
  32.         Set SD = shA.Cells(I, 13)     'Start Date
  33.         Set ED = shA.Cells(I, 14)     'End Date
  34.         If SD.Value > ED.Value Then
  35.             MsgBox "°_©l¤é´Á¡G" & SD.Value & " > ²×¤î¤é´Á¡G" & ED.Value & ", ½Ð¬d©ú¦AÄ~Äò!!", vbOKOnly
  36.             Exit For
  37.         End If
  38.         Set Scel = Rng.Find(SD, Lookat:=xlWhole)       '¦b¦~¾ä¤¤´M§ä Start Date
  39.         If Scel Is Nothing Then
  40.             MsgBox "¬dµL¦¹¤é´Á:" & SD & ", ½Ð¬d©ú¦AÄ~Äò!!", vbOKOnly
  41.             Exit For
  42.         End If
  43.         Set Ecel = Rng.Find(ED, Lookat:=xlWhole)       '¦b¦~¾ä¤¤´M§ä End Date
  44.         If Ecel Is Nothing Then
  45.             MsgBox "¬dµL¦¹¤é´Á:" & ED & ", ½Ð¬d©ú¦AÄ~Äò!!", vbOKOnly
  46.             Exit For
  47.         End If
  48.         
  49.         If Scel.Row = Ecel.Row Then    '¦P¤@¤ë
  50.             Scel.Resize(1, Ecel.Column - Scel.Column + 1).Interior.ColorIndex = 6
  51.         ElseIf Ecel.Row - Scel.Row >= 4 Then    '¸ó«e«á¤ë
  52.             eDay = Day(DateSerial(Year(Scel), Month(Scel) + 1, 0))
  53.             Scel.Resize(1, eDay - Scel.Column + 2).Interior.ColorIndex = 6
  54.             Cells(Ecel.Row, "B").Resize(1, Ecel.Column - 1).Interior.ColorIndex = 6
  55.             If Ecel.Row - Scel.Row > 4 Then     '¸ó¨â¤T¤ë
  56.                 For J = Scel.Row + 4 To Ecel.Row - 4 Step 4
  57.                     Cells(J, "B").Resize(1, Cells(J, "B").End(xlToRight).Column - 1).Interior.ColorIndex = 6
  58.                 Next
  59.             End If
  60.         End If
  61.     Next
  62. End Sub
½Æ»s¥N½X
test.gif

TOP

        ÀR«ä¦Û¦b : ¥ÌÄ@°µ¡BÅw³ß¨ü¡C
ªð¦^¦Cªí ¤W¤@¥DÃD