sspatriots
Well-known Member
- Joined
- Nov 22, 2011
- Messages
- 572
- Office Version
- 365
- Platform
- Windows
Hi,
I'm trying to conditionally format a textbox in my userform. The following code is supposed to turn the textbox backcolor light red and its font dark red if the date is prior to today's date. If the date is between today and the next 30 days the backcolor should turn yellow with a brown color text. The problem is in how I have it written and I don't know how to correct it. This code is turning everything red in that textbox. Not sure what I'm doing wrong here.
I'm trying to conditionally format a textbox in my userform. The following code is supposed to turn the textbox backcolor light red and its font dark red if the date is prior to today's date. If the date is between today and the next 30 days the backcolor should turn yellow with a brown color text. The problem is in how I have it written and I don't know how to correct it. This code is turning everything red in that textbox. Not sure what I'm doing wrong here.
VBA Code:
If Worksheets("Jobs").Cells(i, 24).Value < Date Then
Me.txtCabREQDDate.BackColor = RGB(255, 199, 206)
Me.txtCabREQDDate.ForeColor = RGB(156, 0, 6)
End If
If Worksheets("Jobs").Cells(i, 24).Value >= Date _
And Worksheets("Jobs").Cells(i, 24).Value < Date + 30 Then
Me.txtCabREQDDate.BackColor = RGB(255, 235, 156)
Me.txtCabREQDDate.ForeColor = RGB(156, 87, 0)
End If
Last edited: