Conditional Formatting of Table Cell Value in UserForm

sspatriots

Well-known Member
Joined
Nov 22, 2011
Messages
572
Office Version
  1. 365
Platform
  1. Windows
I'm trying to use "Today()" in my conditional formatting on my UserForm, however, I get the error message "Compile error: Sub or Function not defined". If I use "Today()" in my code that sets the formatting on the worksheet table itself, how come my code for my UserForm won't accept it?

VBA Code:
            'Cab
            If tb.ListColumns("Job" & Chr(10) & "Status").DataBodyRange.Cells(i).Value <> "3 CJN" _
            And tb.ListColumns("Job" & Chr(10) & "Status").DataBodyRange.Cells(i).Value <> "5 CJS" _
            And tb.ListColumns("Job" & Chr(10) & "Status").DataBodyRange.Cells(i).Value <> "6 DOJ" _
            And tb.ListColumns("Job" & Chr(10) & "Status").DataBodyRange.Cells(i).Value <> "7 CXL" _
            And tb.ListColumns("Cab" & Chr(10) & "REQD Date").DataBodyRange.Cells(i).Value < Today() _
            And tb.ListColumns("Cab" & Chr(10) & "REQD Date").DataBodyRange.Cells(i).Value <> "" Then
                Job_Status_PM.txtJobName.BackColor = RGB(255, 199, 206)       'Light Red
                Job_Status_PM.txtJobName.ForeColor = RGB(156, 0, 6)            'Burgundy
                'CF for "Customer Details" Tab
                Job_Status_PM.txtJobName2.BackColor = RGB(255, 199, 206)       'Light Red
                Job_Status_PM.txtJobName2.ForeColor = RGB(156, 0, 6)            'Burgundy


Thanks, SS
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Just found the following, so answered my own question....

Today means the current date. In the worksheet, the NOW function does the same thing, which gives us the current date and time, but there is no built-in Today function in VBA. So instead, the method to get the system's current date is by using the Date function.
 
Upvote 0
Solution

Forum statistics

Threads
1,215,343
Messages
6,124,404
Members
449,156
Latest member
LSchleppi

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