Hi All,
Following on from help in a couple of previous threads I've created a userform with a number of textboxes that are populated when a value is chosen from a combobox and a command button is clicked. In the totals section of this userform, the textbox colour changes depending on the value shown. The issue that I'm having is with one textbox where the value is zero - when it is zero I want it show as green, when "" or "-" I want it to show as grey, and greater than 0 as red. With help on here, I have been using the following code for the textbox in question:
This particular textbox only shows red when there is a 0 (or any other number) and grey for "" or "-", but no green. It is confusing me as another textbox on the userform is using exactly the same code and is working correctly - the only difference is where the information is pulled from??
Can anyone help?
Following on from help in a couple of previous threads I've created a userform with a number of textboxes that are populated when a value is chosen from a combobox and a command button is clicked. In the totals section of this userform, the textbox colour changes depending on the value shown. The issue that I'm having is with one textbox where the value is zero - when it is zero I want it show as green, when "" or "-" I want it to show as grey, and greater than 0 as red. With help on here, I have been using the following code for the textbox in question:
Code:
TextBox162.Text = Worksheets("QtrData").Range("T22").Text
If TextBox162.Text <> "-" Then
If TextBox162.Text <> "" Then
If TextBox162.Text = "0" Then TextBox162.BackColor = RGB(0, 255, 0)
If TextBox162.Text = "0" Then TextBox162.ForeColor = RGB(0, 0, 0)
If TextBox162.Text > "0" Then TextBox162.BackColor = RGB(255, 0, 0)
If TextBox162.Text > "0" Then TextBox162.ForeColor = RGB(0, 0, 0)
End If
End If
If TextBox162.Text = "-" Or TextBox162.Text = "" Then TextBox162.BackColor = RGB(128, 128, 128)
If TextBox162.Text = "-" Or TextBox162.Text = "" Then TextBox162.ForeColor = RGB(0, 0, 0)
This particular textbox only shows red when there is a 0 (or any other number) and grey for "" or "-", but no green. It is confusing me as another textbox on the userform is using exactly the same code and is working correctly - the only difference is where the information is pulled from??
Can anyone help?