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
 

Some videos you may like

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
17,446
Office Version
  1. 2013
Platform
  1. Windows
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
 
L

Legacy 452653

Guest
OH yes sorry you are right should be greater than - but still nothing works

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

Steve
 
L

Legacy 452653

Guest

ADVERTISEMENT

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
 
L

Legacy 452653

Guest
Is there any way too change in Textbox color ...anything greater than 1 ...RED.

Steve
 

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
17,446
Office Version
  1. 2013
Platform
  1. Windows

ADVERTISEMENT

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
 

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
17,446
Office Version
  1. 2013
Platform
  1. Windows
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
 
L

Legacy 452653

Guest
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
 

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
17,446
Office Version
  1. 2013
Platform
  1. Windows
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
 

Watch MrExcel Video

Forum statistics

Threads
1,127,778
Messages
5,626,827
Members
416,202
Latest member
donya ba

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
Top