素人が組む単純なコードですが、ユーザーフォームでの入力作業を許容できるのであれば参考まで。
添付図の赤枠の氏名の一覧、勤務の一覧に、タブ「数式」⇒「名前の管理」でそれぞれに名前を設定します。
ここでは、それぞれの名前を「氏名」、「勤務」としています。
ComboBox1のプロパティ「RowSource」に「氏名」、同様にComboBox2のプロパティ「RowSource」に「勤務」と設定します。
勤務が有給であれば、赤に塗りつぶし休日と表示。
休日であればグレーに塗りつぶし。
その他の勤務であれば、A列の氏名の背景色と同じ背景色とします。
Sub ボタン1_Click()
With UserForm1
.ComboBox1.Value = \u0026quot;\u0026quot;
.TextBox1.Value = \u0026quot;\u0026quot;
.ComboBox2.Value = \u0026quot;\u0026quot;
.Show
End With
End Sub
Private Sub CommandButton1_Click()
Dim c As Long
If TextBox1.Value \u0026lt;\u0026gt; \u0026quot;\u0026quot; Then
For c = 2 To Cells(3, Columns.Count).End(xlToLeft).Column
If DateValue(TextBox1.Value) = Cells(3, c).Value Then
If ComboBox2.Value = \u0026quot;有給\u0026quot; Then
Cells(4 + ComboBox1.ListIndex, c).Value = \u0026quot;休日\u0026quot;
Cells(4 + ComboBox1.ListIndex, c).Interior.ColorIndex = 3
ElseIf ComboBox2.Value = \u0026quot;休日\u0026quot; Then
Cells(4 + ComboBox1.ListIndex, c).Value = \u0026quot;休日\u0026quot;
Cells(4 + ComboBox1.ListIndex, c).Interior.ColorIndex = 48
Else
Cells(4 + ComboBox1.ListIndex, c).Value = ComboBox2.Value
Cells(4 + ComboBox1.ListIndex, c).Interior.ColorIndex _
= Cells(4 + ComboBox1.ListIndex, \u0026quot;A\u0026quot;).Interior.ColorIndex
End If
Exit For
End If
Next c
End If
'リセット
ComboBox1.Value = \u0026quot;\u0026quot;
ComboBox2.Value = \u0026quot;\u0026quot;
TextBox1.Value = \u0026quot;\u0026quot;
ComboBox1.SetFocus
End Sub
Private Sub CommandButton2_Click()
UserForm1.Hide
End Sub