![]() |
Text Box Calculation
I am sure this should be easy :
I am trying to get excel to do a calculation via textboxes. For example If textbox1.value textbox2.value then Textbox1.forecolor = "red" else Textbox1.forecolor = "green" end if It maybe a little more complex because my values are in date format. i.e. textbox1 = "01 jan 2003" textbox2 = "01 jan 2004" Many thanks in advance MArcus |
Text Box Calculation
hi,
tested. it work Private Sub Text11_BeforeUpdate(Cancel As Integer) If Me.Text9.Value Me.Text11.Value Then Me.Text9.ForeColor = RGB(255, 7, 64) 'red Else Me.Text9.ForeColor = RGB(7, 183, 20) 'green End If End Sub Private Sub Text9_BeforeUpdate(Cancel As Integer) If Me.Text9.Value Me.Text11.Value Then Me.Text9.ForeColor = RGB(255, 7, 64) 'red Else Me.Text9.ForeColor = RGB(7, 183, 20) 'green End If End Sub -----Original Message----- I am sure this should be easy : I am trying to get excel to do a calculation via textboxes. For example If textbox1.value textbox2.value then Textbox1.forecolor = "red" else Textbox1.forecolor = "green" end if It maybe a little more complex because my values are in date format. i.e. textbox1 = "01 jan 2003" textbox2 = "01 jan 2004" Many thanks in advance MArcus . |
Text Box Calculation
hi again.
forget the last post. i forgot where i was at and did that for access. sorry here is excel Private Sub TextBox1_Change() If Me.TextBox1.Value Me.TextBox2.Value Then Me.TextBox1.ForeColor = RGB(255, 7, 64) 'red Else Me.TextBox1.ForeColor = RGB(7, 183, 20) 'green End If End Sub Private Sub TextBox2_Change() If Me.TextBox1.Value Me.TextBox2.Value Then Me.TextBox1.ForeColor = RGB(255, 7, 64) 'red Else Me.TextBox1.ForeColor = RGB(7, 183, 20) 'green End If End Sub -----Original Message----- hi, tested. it work Private Sub Text11_BeforeUpdate(Cancel As Integer) If Me.Text9.Value Me.Text11.Value Then Me.Text9.ForeColor = RGB(255, 7, 64) 'red Else Me.Text9.ForeColor = RGB(7, 183, 20) 'green End If End Sub Private Sub Text9_BeforeUpdate(Cancel As Integer) If Me.Text9.Value Me.Text11.Value Then Me.Text9.ForeColor = RGB(255, 7, 64) 'red Else Me.Text9.ForeColor = RGB(7, 183, 20) 'green End If End Sub -----Original Message----- I am sure this should be easy : I am trying to get excel to do a calculation via textboxes. For example If textbox1.value textbox2.value then Textbox1.forecolor = "red" else Textbox1.forecolor = "green" end if It maybe a little more complex because my values are in date format. i.e. textbox1 = "01 jan 2003" textbox2 = "01 jan 2004" Many thanks in advance MArcus . . |
Text Box Calculation
Just note that your doing a string compare which may or may not work.
I suggest you do Private Sub TextBox1_Change() If cDate(Me.TextBox1.Value) cDate(Me.TextBox2.Value) Then Me.TextBox1.ForeColor = RGB(255, 7, 64) 'red Else Me.TextBox1.ForeColor = RGB(7, 183, 20) 'green End If End Sub -- Regards, Tom Ogilvy wrote in message ... hi again. forget the last post. i forgot where i was at and did that for access. sorry here is excel Private Sub TextBox1_Change() If Me.TextBox1.Value Me.TextBox2.Value Then Me.TextBox1.ForeColor = RGB(255, 7, 64) 'red Else Me.TextBox1.ForeColor = RGB(7, 183, 20) 'green End If End Sub Private Sub TextBox2_Change() If Me.TextBox1.Value Me.TextBox2.Value Then Me.TextBox1.ForeColor = RGB(255, 7, 64) 'red Else Me.TextBox1.ForeColor = RGB(7, 183, 20) 'green End If End Sub -----Original Message----- hi, tested. it work Private Sub Text11_BeforeUpdate(Cancel As Integer) If Me.Text9.Value Me.Text11.Value Then Me.Text9.ForeColor = RGB(255, 7, 64) 'red Else Me.Text9.ForeColor = RGB(7, 183, 20) 'green End If End Sub Private Sub Text9_BeforeUpdate(Cancel As Integer) If Me.Text9.Value Me.Text11.Value Then Me.Text9.ForeColor = RGB(255, 7, 64) 'red Else Me.Text9.ForeColor = RGB(7, 183, 20) 'green End If End Sub -----Original Message----- I am sure this should be easy : I am trying to get excel to do a calculation via textboxes. For example If textbox1.value textbox2.value then Textbox1.forecolor = "red" else Textbox1.forecolor = "green" end if It maybe a little more complex because my values are in date format. i.e. textbox1 = "01 jan 2003" textbox2 = "01 jan 2004" Many thanks in advance MArcus . . |
Text Box Calculation
.... and this works? Or not.
Geof. -----Original Message----- hi again. forget the last post. i forgot where i was at and did that for access. sorry here is excel Private Sub TextBox1_Change() If Me.TextBox1.Value Me.TextBox2.Value Then Me.TextBox1.ForeColor = RGB(255, 7, 64) 'red Else Me.TextBox1.ForeColor = RGB(7, 183, 20) 'green End If End Sub Private Sub TextBox2_Change() If Me.TextBox1.Value Me.TextBox2.Value Then Me.TextBox1.ForeColor = RGB(255, 7, 64) 'red Else Me.TextBox1.ForeColor = RGB(7, 183, 20) 'green End If End Sub -----Original Message----- hi, tested. it work Private Sub Text11_BeforeUpdate(Cancel As Integer) If Me.Text9.Value Me.Text11.Value Then Me.Text9.ForeColor = RGB(255, 7, 64) 'red Else Me.Text9.ForeColor = RGB(7, 183, 20) 'green End If End Sub Private Sub Text9_BeforeUpdate(Cancel As Integer) If Me.Text9.Value Me.Text11.Value Then Me.Text9.ForeColor = RGB(255, 7, 64) 'red Else Me.Text9.ForeColor = RGB(7, 183, 20) 'green End If End Sub -----Original Message----- I am sure this should be easy : I am trying to get excel to do a calculation via textboxes. For example If textbox1.value textbox2.value then Textbox1.forecolor = "red" else Textbox1.forecolor = "green" end if It maybe a little more complex because my values are in date format. i.e. textbox1 = "01 jan 2003" textbox2 = "01 jan 2004" Many thanks in advance MArcus . . . |
Text Box Calculation
Many thanks all I think it works although sometimes the
textbox does automatically change when date is entered. -----Original Message----- .... and this works? Or not. Geof. -----Original Message----- hi again. forget the last post. i forgot where i was at and did that for access. sorry here is excel Private Sub TextBox1_Change() If Me.TextBox1.Value Me.TextBox2.Value Then Me.TextBox1.ForeColor = RGB(255, 7, 64) 'red Else Me.TextBox1.ForeColor = RGB(7, 183, 20) 'green End If End Sub Private Sub TextBox2_Change() If Me.TextBox1.Value Me.TextBox2.Value Then Me.TextBox1.ForeColor = RGB(255, 7, 64) 'red Else Me.TextBox1.ForeColor = RGB(7, 183, 20) 'green End If End Sub -----Original Message----- hi, tested. it work Private Sub Text11_BeforeUpdate(Cancel As Integer) If Me.Text9.Value Me.Text11.Value Then Me.Text9.ForeColor = RGB(255, 7, 64) 'red Else Me.Text9.ForeColor = RGB(7, 183, 20) 'green End If End Sub Private Sub Text9_BeforeUpdate(Cancel As Integer) If Me.Text9.Value Me.Text11.Value Then Me.Text9.ForeColor = RGB(255, 7, 64) 'red Else Me.Text9.ForeColor = RGB(7, 183, 20) 'green End If End Sub -----Original Message----- I am sure this should be easy : I am trying to get excel to do a calculation via textboxes. For example If textbox1.value textbox2.value then Textbox1.forecolor = "red" else Textbox1.forecolor = "green" end if It maybe a little more complex because my values are in date format. i.e. textbox1 = "01 jan 2003" textbox2 = "01 jan 2004" Many thanks in advance MArcus . . . . |
All times are GMT +1. The time now is 12:23 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com