P
Prohock
I have a series of text boxes that change color depending on what option
button is selected. How can I condense the code below so that it could work
with hundreds of text boxes i.e. text99? I am new to VBA and I think that I
have to use variables?
Private Sub Text1_Click()
If Me.Option1 = True Then
Me.Text1.BackColor = RGB(164, 211, 238)
Else
If Me.Option2 = True Then
Me.Text1.BackColor = RGB(216, 191, 216)
Else
If Me.Option3 = True Then
Me.Text1.BackColor = RGB(255, 214, 159)
Else
Me.Text1.BackColor = 15329774
End If
End If
End If
End Sub
Private Sub Text2_Click()
If Me.Option1 = True Then
Me.Text2.BackColor = RGB(164, 211, 238)
Else
If Me.Option2 = True Then
Me.Text2.BackColor = RGB(216, 191, 216)
Else
If Me.Option3 = True Then
Me.Text2.BackColor = RGB(255, 214, 159)
Else
Me.Text2.BackColor = 15329774
End If
End If
End If
End Sub
button is selected. How can I condense the code below so that it could work
with hundreds of text boxes i.e. text99? I am new to VBA and I think that I
have to use variables?
Private Sub Text1_Click()
If Me.Option1 = True Then
Me.Text1.BackColor = RGB(164, 211, 238)
Else
If Me.Option2 = True Then
Me.Text1.BackColor = RGB(216, 191, 216)
Else
If Me.Option3 = True Then
Me.Text1.BackColor = RGB(255, 214, 159)
Else
Me.Text1.BackColor = 15329774
End If
End If
End If
End Sub
Private Sub Text2_Click()
If Me.Option1 = True Then
Me.Text2.BackColor = RGB(164, 211, 238)
Else
If Me.Option2 = True Then
Me.Text2.BackColor = RGB(216, 191, 216)
Else
If Me.Option3 = True Then
Me.Text2.BackColor = RGB(255, 214, 159)
Else
Me.Text2.BackColor = 15329774
End If
End If
End If
End Sub