Conditional Format Textbox in Userform

sspatriots

Well-known Member
Joined
Nov 22, 2011
Messages
572
Office Version
  1. 365
Platform
  1. 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.

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:

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
I think I have solved my own issue on this one. Looks like it was just placed in the wrong area of the other code that it is with. I moved it and it works now.
 
Upvote 0
Solution

Forum statistics

Threads
1,215,220
Messages
6,123,693
Members
449,117
Latest member
Aaagu

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