Share via

Excel If/Or Macro question - help!

Anonymous
2024-08-28T17:54:11+00:00

Hi....

I'm trying to write what I thought was a simple excel macro, but it seems to be failing. Here is what I am trying to do.... I've tried nested macros etc., but I'm missing something....

Cell A1 = Yes or No;

Cell B1 = a value of 18 or 20;

Cell C1 contains a formatted date value DD-MM-YYYY (representing the date for 18 years);

Cell D1 contains the formatted date value DD-MM-YYY (representing the date for 20 years).

Cell E1 is where I want the formula and results to display

What I am trying to do is basically create a formula for cell E1 that says:

"If A1 = "Yes"; and B1 =18, then display the date from C1. But if Cell A1="Yes" and B1 = 20, then instead display the date from D1", and if the value is neither 18 or 20, then display blank (or leave blank)

Here's one of several I've tried and it gives me errors:

=IF(OR(A1="Yes",IF(B1=20,C1,""),IF(A1="Yes",IF(B1=18,C2,""))))

Tried this too...

=IF(OR(AND(A1="Yes",B1=18,C1,AND(A1="Yes",B1=20,D1,""))))

Microsoft 365 and Office | Excel | For business | Other

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

3 answers

Sort by: Most helpful
  1. Anonymous
    2024-08-29T12:57:23+00:00

    Got the date formats fixed! Thanks for the help! :-)

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2024-08-29T12:50:20+00:00

    The logic part works perfectly – thanks….. but now the dates are giving me 1900 and 1901 instead of 2030! LOL

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2024-08-28T22:01:24+00:00

    Hi Dave

    Please, try the following formula

    =IF(AND(A1="Yes",B1=18),C1,IF(AND(A1="Yes",B1=20),D1,""))

    I hope this helps you

    Regards

    Jeovany

    Was this answer helpful?

    0 comments No comments