Textbox value change to Red if greater than 0

L

Legacy 452653

Guest
Hi,

I was sure that the following code below changes to Red if my Cell from E34 ( 1 ) and Cell (Q34) is ( 0 ) then please change my Textbox to "RED".

Can someone check please - cause it aint working.

Private Sub Textbox32_Change()
If Sheet5.Range("E34").Value > Sheet5.Range("Q34").Value Then

Me.Textbox32.Backcolor = vbRed
Else
Me.Textbox32.Backcolor = vbGreen
End If
End Sub
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Here you say:
if my Cell from E34 ( 1 ) and Cell (Q34) is ( 0 ) then please change my Textbox to "RED".

Looks like your saying if both are 0

But here you say:
If Sheet5.Range("E34").Value > Sheet5.Range("Q34").Value Then


Your saying if E34 is greater then Q34

Or Maybe E34 (1) means if it equals 1
 
Upvote 0
OH yes sorry you are right should be greater than - but still nothing works

If Sheet5.Range("E34").Value < Sheet5.Range("Q34").Value

Steve
 
Upvote 0
Then I was right
If Sheet5.Range("E34").Value > Sheet5.Range("Q34").Value Then
Me.Textbox32.Backcolor = vbRed
Else
Me.Textbox32.Backcolor = vbGreen
End If
End Sub

Even then it should turn green.

But nothing happens
 
Upvote 0
Is there any way too change in Textbox color ...anything greater than 1 ...RED.

Steve
 
Upvote 0
Your script works for me.

I assume your using a Userform is that true?

What is happenings Is the textbox not changing to any color
 
Upvote 0
You said:
Is there any way too change in Textbox color ...anything greater than 1 ...RED.

What does that mean.?
anything

And I assume your putting this script in a button.
Or are you entering the script in the TextBox
 
Upvote 0
Hi,

All I need in the textbox in the userform. Textbox has the number 1. I have a cell that has a ZERO.

The formula that i have below regardless of less than or greater than I want it too change either red or green.

Private Sub Textbox32_Change()
If Sheet5.Range("E34").Value > Sheet5.Range("Q34").Value Then

Me.Textbox32.Backcolor = vbRed
Else
Me.Textbox32.Backcolor = vbGreen
End If
End Sub
 
Upvote 0
Well your script works for me.
But the script only runs when you enter something in The TextBox
So you must enter something in the TextBox for the script to run
 
Upvote 0

Forum statistics

Threads
1,224,813
Messages
6,181,118
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top