|
こんにちは
参考までに(すべてUserFormのモジュールにて)
変数「Cor」「Cor1」はモジュールの先頭にて宣言
Dim Cor, Cor1
Private Sub ComboBox1_Change()
Dim La As Variant, Te As Variant, La1 As Variant
Dim Co As Long, i As Long, Te1 As Variant
La = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30)
Te = Array(15, 16, 17, 18, 19, 20, 40, 41, 42, 43, 44, 45)
La1 = Array(1, 2, 3, 4, 5, 15, 16, 17, 18, 19, 20)
Te1 = Array(10, 11, 12, 13, 14, 15, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45)
Select Case Val(Me.ComboBox1.Value)
Case 4: Co = 1
Case 5: Co = 2
Case Else: Co = 0
End Select
For i = 1 To 45
If Co = 1 Then
Call Color_Check(La, Te, CStr(i))
ElseIf Co = 2 Then
Call Color_Check(La1, Te1, CStr(i))
Else
Cor = &H8000000F: Cor1 = &H80000005
End If
If i < 31 Then
Me.Controls("Label" & i).BackColor = Cor
Me.Controls("Label" & i).Caption = i
Me.Controls("TextBox" & i).BackColor = Cor1
Me.Controls("TextBox" & i).Value = i
Else
Me.Controls("TextBox" & i).BackColor = Cor1
Me.Controls("TextBox" & i).Value = i
End If
Next
End Sub
Private Sub Color_Check(Da As Variant, Da1 As Variant, Cou As Long)
Dim Ma As Variant, Ma1 As Variant
Ma = Application.Match(Cou, Da, 0)
If Not IsError(Ma) Then
Cor = &HFF&
Else
Cor = &H8000000F
End If
Ma1 = Application.Match(Cou, Da1, 0)
If Not IsError(Ma1) Then
Cor1 = &HFF&
Else
Cor1 = &H80000005
End If
End Sub
|
|