R
Robert
Hello,
My problem is the following I have a lot of labels which have to
change from color if a value is reached.
Private Sub UserForm_Click()
' # labels = 86
' height = 1.2
' fractions
y1 = (1 / 86) * 1.2
y2 = (2 / 86) * 1.2
y3 = (3 / 86) * 1.2
y4 = (4 / 86) * 1.2
y5 = (5 / 86) * 1.2
y6 = (6 / 86) * 1.2
y7 = (7 / 86) * 1.2
y8 = (8 / 86) * 1.2
y9 = (9 / 86) * 1.2
y10 = (10 / 86) * 1.2
y11 = (11 / 86) * 1.2
y12 = (12 / 86) * 1.2
'etc. till y86
If the Height (which is the value in Cell B14) is bigger then a
fraction the corresponding label should swich of colour
which I put like this:
If Cells(14, "B").Value > y1 Then label0.ForeColor = RGB(0, 0, 0)
If Cells(14, "B").Value > y2 Then Label1.ForeColor = RGB(0, 0, 0)
If Cells(14, "B").Value > y3 Then Label2.ForeColor = RGB(0, 0, 0)
If Cells(14, "B").Value > y4 Then Label3.ForeColor = RGB(0, 0, 0)
If Cells(14, "B").Value > y5 Then Label4.ForeColor = RGB(0, 0, 0)
etc..till label85 (since I started @ label0)
But there should be a easier way I guess:S.
And there is one more thing. I have a reset button placed on the
userform.
If clicked, then it should trigger the code to give all the labels the
initial colour.
I have this know also put as above. which 86 lines of code.
Any suggestions would be welcome.
My problem is the following I have a lot of labels which have to
change from color if a value is reached.
Private Sub UserForm_Click()
' # labels = 86
' height = 1.2
' fractions
y1 = (1 / 86) * 1.2
y2 = (2 / 86) * 1.2
y3 = (3 / 86) * 1.2
y4 = (4 / 86) * 1.2
y5 = (5 / 86) * 1.2
y6 = (6 / 86) * 1.2
y7 = (7 / 86) * 1.2
y8 = (8 / 86) * 1.2
y9 = (9 / 86) * 1.2
y10 = (10 / 86) * 1.2
y11 = (11 / 86) * 1.2
y12 = (12 / 86) * 1.2
'etc. till y86
If the Height (which is the value in Cell B14) is bigger then a
fraction the corresponding label should swich of colour
which I put like this:
If Cells(14, "B").Value > y1 Then label0.ForeColor = RGB(0, 0, 0)
If Cells(14, "B").Value > y2 Then Label1.ForeColor = RGB(0, 0, 0)
If Cells(14, "B").Value > y3 Then Label2.ForeColor = RGB(0, 0, 0)
If Cells(14, "B").Value > y4 Then Label3.ForeColor = RGB(0, 0, 0)
If Cells(14, "B").Value > y5 Then Label4.ForeColor = RGB(0, 0, 0)
etc..till label85 (since I started @ label0)
But there should be a easier way I guess:S.
And there is one more thing. I have a reset button placed on the
userform.
If clicked, then it should trigger the code to give all the labels the
initial colour.
I have this know also put as above. which 86 lines of code.
Any suggestions would be welcome.