An excel formula needed to determine T/F on dates

ItalianPlatinum

Well-known Member
Joined
Mar 23, 2017
Messages
857
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hello,
I need some help trying to create a formula that will identify if the date1 and date2 don't equal next BD -2 (i have that formula in a cell to reference).

There are a few variables though:
  1. indicator "I" will have the date 2 as 0
  2. indicator I and A date 1 and date 2 will be on a last BD of prior month -1 date on every BD 1 (this is ok). (i also have that formula in a cell to reference)
I know a lot going on. ideally would like 1 formula unless i need multiple helper columns to bring it together?

Book1
ABCDEFGHIJK
1AccountIndicatorDate 1Date 2Formula (HELP)Desired ResultNext BD -220230731LAST BD PM-120230730
21F2023073120230731FALSE
32F2023073120230731FALSE
43F2023073120230731FALSE
54F2023073120230731FALSE
65F2023073120230731FALSE
76F2023073120230731FALSE
87F2023073020230730TRUETEST
98F2023073020230731TRUETEST
109F2023073120230730TRUETEST
111I202307310TRUETEST
122I202307290TRUETEST
133I202307300FALSE
144I202307300FALSE
155I202307300FALSE
166I202307300FALSE
177I202307300FALSE
188I202307300FALSE
199I202307300FALSE
201A2023073020230730FALSE
212A2023073020230731TRUETEST
223A2023073120230730TRUETEST
234A2023072920230730TRUETEST
245A2023073020230729TRUETEST
256A2023073020230730FALSE
267A2023073020230730FALSE
278A2023073020230730FALSE
289A2023073020230730FALSE
Sheet1
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
See if the following formula works for you:
Excel Formula:
=OR(IF(B2="F",$I$1,$K$1)<>C2,IF(B2="F",$I$1,$K$1)<>IF(D2,D2,C2))
The formula can be compacted further, but in Excel 2016 it would need to be entered using Ctrl+Shift+Enter, not just Enter:
Excel Formula:
=OR(IF(B2="F",$I$1,$K$1)<>CHOOSE({1,2},C2,IF(D2,D2,C2)))
 
Upvote 0
sorry one addition, there is actually another indicator "B", that isnt being captured when applying this. indicators F and B operate the same. I and A operate with the variable 2, while indicator I has variable 1 as well. Apologies should've included see below:

Book1
ABCDEFGHIJK
1AccountIndicatorDate 1Date 2Formula (HELP)Desired ResultNext BD -220230731LAST BD PM-120230730
21F2023073120230731FALSEFALSE
32F2023073120230731FALSEFALSE
43F2023073120230731FALSEFALSE
54F2023073120230731FALSEFALSE
65F2023073120230731FALSEFALSE
76F2023073120230731FALSEFALSE
87F2023073020230730TRUETRUETEST
98F2023073020230731TRUETRUETEST
109F2023073120230730TRUETRUETEST
111I202307310TRUETRUETEST
122I202307290TRUETRUETEST
133I202307300FALSEFALSE
144I202307300FALSEFALSE
155I202307300FALSEFALSE
166I202307300FALSEFALSE
177I202307300FALSEFALSE
188I202307300FALSEFALSE
199I202307300FALSEFALSE
201A2023073020230730FALSEFALSE
212A2023073020230731TRUETRUETEST
223A2023073120230730TRUETRUETEST
234A2023072920230730TRUETRUETEST
245A2023073020230729TRUETRUETEST
256A2023073020230730FALSEFALSE
267A2023073020230730FALSEFALSE
278A2023073020230730FALSEFALSE
289A2023073020230730FALSEFALSE
291B2023073120230731TRUEFALSE
302B2023073120230731TRUEFALSE
313B2023073120230731TRUEFALSE
324B2023073120230731TRUEFALSE
335B2023073120230731TRUEFALSE
346B2023073120230731TRUEFALSE
357B2023073020230730FALSETRUETEST
368B2023073020230731TRUETRUETEST
379B2023073120230730TRUETRUETEST
Sheet1
Cell Formulas
RangeFormula
E2E2=OR(IF(B2="F",$I$1,$K$1)<>CHOOSE({1,2},C2,IF(D2,D2,C2)))
E3:E37E3=OR(IF(B3="F",$I$1,$K$1)<>CHOOSE({1,2},C3,IF(D3,D3,C3)))
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
See if the following updated formula works for you:
Excel Formula:
=OR(IF(OR(B2={"A","I"}),$K$1,$I$1)<>CHOOSE({1,2},C2,IF(D2,D2,C2)))
 
Upvote 0
Solution
Few of my test conditions are failing are you seeing the same? seem like conditions where one or the other isn't the right date not identifying as an issue

Book1
ABCDEFGHIJK
1AccountIndicatorDate 1Date 2Formula (HELP)Desired ResultNext BD -220230731LAST BD PM-120230730
21F2023073120230731FALSEFALSE
32F2023073120230731FALSEFALSE
43F2023073120230731FALSEFALSE
54F2023073120230731FALSEFALSE
65F2023073120230731FALSEFALSE
76F2023073120230731FALSEFALSE
87F2023073020230730TRUETRUETEST
98F2023073020230731TRUETRUETEST
109F2023073120230730FALSETRUETEST
111I202307310TRUETRUETEST
122I202307290TRUETRUETEST
133I202307300FALSEFALSE
144I202307300FALSEFALSE
155I202307300FALSEFALSE
166I202307300FALSEFALSE
177I202307300FALSEFALSE
188I202307300FALSEFALSE
199I202307300FALSEFALSE
201A2023073020230730FALSEFALSE
212A2023073020230731FALSETRUETEST
223A2023073120230730TRUETRUETEST
234A2023072920230730TRUETRUETEST
245A2023073020230729FALSETRUETEST
256A2023073020230730FALSEFALSE
267A2023073020230730FALSEFALSE
278A2023073020230730FALSEFALSE
289A2023073020230730FALSEFALSE
291B2023073120230731FALSEFALSE
302B2023073120230731FALSEFALSE
313B2023073120230731FALSEFALSE
324B2023073120230731FALSEFALSE
335B2023073120230731FALSEFALSE
346B2023073120230731FALSEFALSE
357B2023073020230730TRUETRUETEST
368B2023073020230731TRUETRUETEST
379B2023073120230730FALSETRUETEST
Sheet1
Cell Formulas
RangeFormula
E2:E37E2=OR(IF(OR(B2={"A","I"}),$K$1,$I$1)<>CHOOSE({1,2},C2,IF(D2,D2,C2)))
 
Upvote 0
Few of my test conditions are failing...
Most likely, you did not enter the formula using Ctrl+Shift+Enter. The array formula from Post #4 has been tested to return the expected results in both Excel 2010 and Excel 2021.

To avoid confusion, try using a regular (i.e., non-array) version of the formula:
Excel Formula:
=OR(IF(OR(B2={"A","I"}),$K$1,$I$1)<>C2,IF(OR(B2={"A","I"}),$K$1,$I$1)<>IF(D2,D2,C2))
 
Upvote 0
oh your right on the array. How do I apply that via VBA then? i was doing this:

VBA Code:
.Range("Y11:Y" & Cells(rows.count, 16).End(xlUp).row).Formula =
 
Upvote 0
@ItalianPlatinum try applying the array formula like below

VBA Code:
Sub test()

    With Range("E2:E37")
        .Formula = "=OR(IF(OR(B2={""A"",""I""}),$K$1,$I$1)<>CHOOSE({1,2},C2,IF(D2,D2,C2)))"
        .FormulaArray = .FormulaR1C1
    End With
 
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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