Hello Everyone,
I have this problem on my code.
basically, I wanted to change a textbox color if that value of a particular textbox is less than 95%.
But i'm having no luck. My guess is, this has something to do with the textbox converting to Numbers or percentage.
Any idea why? Haay..
Thanks In Advance guys.
Below is my code.
I have this problem on my code.
basically, I wanted to change a textbox color if that value of a particular textbox is less than 95%.
But i'm having no luck. My guess is, this has something to do with the textbox converting to Numbers or percentage.
Any idea why? Haay..
Thanks In Advance guys.
Below is my code.
VBA Code:
Private Sub ComboBox1_Change()
Dim i As Long, LastRow As Long, ws As Worksheet
Set ws = Sheets("Sheet2")
LastRow = ws.Range("B" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
If Me.ComboBox1.Value = ws.Cells(i, "B") Then
Me.txt2 = ws.Cells(i, "B").Value
Me.txt3 = ws.Cells(i, "C").Value
Me.txt4 = ws.Cells(i, "D").Value
Me.txt5 = ws.Cells(i, "E").Value
Me.txt6 = Format(ws.Cells(i, "F").Value, "0.00%")
Me.txt7 = ws.Cells(i, "G").Value
Me.txt8 = ws.Cells(i, "H").Value
Me.txt9 = Format(ws.Cells(i, "I").Value, "0.00")
End If
Next i
If Me.ComboBox1.Value = "" Then
Me.txt2 = ""
Me.txt3 = ""
Me.txt4 = ""
Me.txt5 = ""
Me.txt6 = ""
Me.txt7 = ""
Me.txt8 = ""
Me.txt9 = ""
End If
If CDbl(txt6.Value) < 95 Then
txt6.BackColor = vbRed
Else
txt6.BackColor = vbGreen
End If
If txt9.Value < 3 Then
txt6.BackColor = vbRed
Else
txt9.BackColor = vbGreen
End If
End Sub