VBA or Formula to tell me if the Date in Column C is less than Column B

APML

Board Regular
Joined
Sep 10, 2021
Messages
216
Office Version
  1. 365
Hi all, I have 2 columns. Column B is an “Entry Date”, and Column C is an "Exit Date".

Column B starts at B7 and finishes at B3000 Column C starts at C7 and finishes at C3000

They will always only be direct comparisons i.e B70 will only be compared to C70
And if either cell is empty, then I don't want anything



Basically, I need a formula that will tell me if the Date in Column C is less than the Date in Column B
They can and often will be the same date, or Column C will be higher.

Here is an example:
Let’s say in B100 I have the date 02/10/22 (day, mth, year) and in C100 I accidentally put in 01/10/22, then I’d want something like “Exit Date cannot be less than Entry Date”.

I understand that I could put an if statement in Column D and copy all the way down D300

But was hoping I could just do the whole thing with 1 formula or VBA

Thanks for reading this and I really appreciate any help given
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
An option is to use Power Query

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Entry", type date}, {"Exit", type date}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if[Exit]<[Entry] then 1 else null)
in
    #"Added Custom"
 
Upvote 0
An option is to use Power Query

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Entry", type date}, {"Exit", type date}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if[Exit]<[Entry] then 1 else null)
in
    #"Added Custom"
To hard for this application
 
Upvote 0

Forum statistics

Threads
1,214,875
Messages
6,122,044
Members
449,063
Latest member
ak94

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