Excel cell conditional Formatting using VBA

Nikhil2803

New Member
Joined
Jul 18, 2023
Messages
37
Office Version
  1. 365
Platform
  1. Windows
I have a cell in excel sheet that contains data that should be in date format. I need to give the conditions as : "A Date of Birth that is under 16, over 100 or after the Date of Hire" should be an invalid. Please help my how to achieve this using VBA in excel.
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
What columns are Date of Birth and Date of Hire in?

Also, I am a little unclear as to what method you want to use, as:
- Conditional Formatting can only format cells (i.e. change color, font, etc). It cannot prevent entries, only highlight them.
- Data Validation can be used to prevent entries and pop-up error methods. See this link here: Custom Data Validation in Excel : formulas and rules
- VBA can be used to to do all of that (prevent entries, pop-up error messages, format cells, etc)

So how exactly do you want this to work? Do you actually want to prevent the values from being entered, pop-up error messages, or just format the offending cells?
 
Upvote 0

Forum statistics

Threads
1,223,898
Messages
6,175,274
Members
452,628
Latest member
dd2

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