Dim kigen As String Sub ki010() Application.ScreenUpdating = False ThisWorkbook.Activate Sheets("Sheet1").Select date1 = Date If Cells(50, 1) = "" Then Rows("50:50").RowHeight = 0 Cells(50, 1) = date1 + 10 ActiveSheet.Protect password:="0000" ActiveWorkbook.Save date2 = date1 + 10 MsgBox "有効期限「" & date2 & "」となっています" kigen = 1 Else date2 = Cells(50, 1) If date1 > date2 Then MsgBox "「" & date2 & "」で有効期限が切れました。" Sheets("Title").Select kigen = 0 Exit Sub Else MsgBox "有効期限「" & date2 & "」となっています" kigen = 1 End If End If Sheets("Title").Select Application.ScreenUpdating = True ki010a End Sub Sub ki010a() For i = 3 To 11 Cells(9, i).Interior.ColorIndex = Int(56 * Rnd + 1) Next Cells(9, 4) = "セルに色を付けるマクロを実行しました" End Sub Sub ki010b() Application.ScreenUpdating = False ThisWorkbook.Activate Sheets("Sheet1").Select If Cells(50, 1) = "" Then MsgBox "有効期日は設定されていません" Else MsgBox "有効期日は「" & Cells(50, 1) & "」に設定されている" ActiveSheet.Unprotect password:="0000" Cells(50, 1) = "" MsgBox "有効期日を解除しました" End If Sheets("Title").Select Range("C9:k9").Interior.ColorIndex = xlNone Range("D9") = "" End Sub Sub ki010c() Application.ScreenUpdating = False ThisWorkbook.Activate Sheets("Sheet1").Select ActiveSheet.Unprotect password:="0000" Cells(50, 1) = Date - 1 MsgBox "有効期日を" & Date - 1 & "に設定しました" Sheets("Title").Select Range("C9:k9").Interior.ColorIndex = xlNone Range("D9") = "" End Sub