Code not returning data i want

erimhast83

New Member
Joined
Jan 3, 2018
Messages
14
ActiveCell.FormulaR1C1 = _
"=IF(AND(RC[2]=""DUCK,DONALD"", RC[2]=""RABBIT,ROGER"",RC[2]=""MOUSE,MINNIE"",RC[2]=""DUCK,DAISY"",RC[12]=""WHITE,SNOW"",RC[2]=""DOE, JOHN"",RC[2]=""DOE, JANE""), ""DUCK,DONALD"",""DOO, SCOOBY"")"

The above code should bring back DUCK,DONALD but is bringing back DOO,SCOOBY.

Can anyone see what I am doing wrong in my code?

Thank you,
E.
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Why would that return Duck,Donald?

AND requires ALL criteria to be true.
It is not possible for ALL the criteria in your AND to be true.
Just looking at 2 criteria, it is impossible for RC[2] to be Duck,Donald AND Rabbit,Roger.

I think you mean for that to be an OR.
 
Upvote 0
I think maybe you meant to use OR instead of AND.
In order for AND to return true, ALL of the things you are checking for must be true.
There is now way a cell can be equal to both "DUCK,DONALD" and "RABBIT,ROGER" at the same time. It is either one or the other, or neither.
For an OR statement to be true, only one of your checks need to be true.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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