| 
    
     |  | 最終的には、 
 シート(セル)は保護したい。
 コピーペーストの場合も、入力規則は不変としたい。
 入力文字を見やすくするようfont色を変える。
 
 を織り込み、以下のコードで落ち着きました。
 
 ありがとうございました。
 
 
 Private Sub Worksheet_Change(ByVal Target As Range)
 
 Dim ra As Range
 If (Application.Intersect(Target, Range(Cells(1, 1), Cells(1, 50))) Is Nothing) Then Exit Sub
 For Each ra In Target
 If Application.CutCopyMode <> False Then Application.CutCopyMode = False
 ActiveSheet.Unprotect
 If ra.Value = "" Then
 ra.Interior.ColorIndex = xlNone '空欄なら無色
 '      ra.BorderAround LineStyle:=xlContinuous, Weight:=xlThin, ColorIndex:=xlAutomatic
 ra.Font.ColorIndex = 1
 Else
 ra.Interior.ColorIndex = ra.Value '着色
 ra.BorderAround LineStyle:=xlContinuous, Weight:=xlThin, ColorIndex:=xlAutomatic
 Select Case ra.Value
 Case 2, 6, 19, 20, 24, 27, 34 To 40
 ra.Font.ColorIndex = 1
 Case Else
 ra.Font.ColorIndex = 2
 End Select
 End If
 ActiveSheet.Protect
 Next
 End Sub
 
 
 |  |