Shorten "OR" formula

Lux Aeterna

Board Regular
Joined
Aug 27, 2015
Messages
114
Office Version
  1. 2019
Platform
  1. Windows
Hello again!

I've got a huge formula that I'd like to shorten, in order to be able to expand cell range more easily if necessary. And make it more readable, of course. Problem is with OR function, as I had to include each cell separately. I tried using OR(C8=W3:W16), but it doesn't seem to work. Thank you in advance!
=IF(C8="";"";IF(OR(C8=$W$3;C8=$W$4;C8=$W$5;C8=$W$6;C8=$W$7;C8=$W$8;C8=$W$9;C8=$W$10;C8=$W$11;C8=$W$12;C8=$W$13;C8=$W$14;C8=$W$15;C8=$W$16;C8=$W$17;C8=$W$18);"Αργία";IF(OR(C8=$N$3;C8=$N$4;C8=$N$5;C8=$N$6;C8=$N$7;C8=$N$8;C8=$N$9;C8=$N$10;C8=$N$11;C8=$N$12;C8=$N$13;C8=$N$14;C8=$N$15;C8=$N$16;C8=$N$17;C8=$N$18;C8=$N$19;C8=$N$20;C8=$N$21;C8=$N$22;C8=$N$23;C8=$N$24;C8=$N$25);$C$39;IF(OR(C8=$O$3;C8=$O$4;C8=$O$5;C8=$O$6;C8=$O$7;C8=$O$8;C8=$O$9;C8=$O$10;C8=$O$11;C8=$O$12;C8=$O$13;C8=$O$14;C8=$O$15;C8=$O$16;C8=$O$17;C8=$O$18;C8=$O$19;C8=$O$20;C8=$O$21;C8=$O$22;C8=$O$23;C8=$O$24;C8=$O$25);"Ρεπό";IF(OR(C8=$P$3;C8=$P$4;C8=$P$5;C8=$P$6;C8=$P$7;C8=$P$8;C8=$P$9;C8=$P$10;C8=$P$11;C8=$P$12;C8=$P$13;C8=$P$14;C8=$P$15;C8=$P$16;C8=$P$17;C8=$P$18;C8=$P$19;C8=$P$20;C8=$P$21;C8=$P$22;C8=$P$23;C8=$P$24;C8=$P$25);"Κανονική";IF(OR(C8=$Q$3;C8=$Q$4;C8=$Q$5;C8=$Q$6);"Γονική";IF(OR(C8=$R$3;C8=$R$4;C8=$R$5;C8=$R$6);"Φοιτητική";IF(OR(C8=$S$3;C8=$S$4;C8=$S$5;C8=$S$6;C8=$S$7;C8=$S$8;C8=$S$9;C8=$S$10;C8=$S$11;C8=$S$12);"Εκπαιδευτική";IF(OR(C8=$T$3;C8=$T$4;C8=$T$5;C8=$T$6;C8=$T$7;C8=$T$8;C8=$T$9;C8=$T$10;C8=$T$11;C8=$T$12;C8=$T$13;C8=$T$14;C8=$T$15;C8=$T$16;C8=$T$17;C8=$T$18;C8=$T$19;C8=$T$20;C8=$T$21;C8=$T$22;C8=$T$23;C8=$T$24;C8=$T$25;C8=$T$26;C8=$T$27;C8=$T$28;C8=$T$29;C8=$T$30;C8=$T$31;C8=$T$32;C8=$T$33);"Αναρρωτική";IF(OR(C8=$U$3;C8=$U$4);"Νόμου 105";IF(OR(C8=$V$3;C8=$V$4;C8=$V$5;C8=$V$6;C8=$V$7;C8=$V$8;C8=$V$9;C8=$V$10;C8=$V$11;C8=$V$12);"Ειδική";$B$39)))))))))))
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
66,156
Office Version
  1. 365
Platform
  1. Windows
You are right, I had mistyped some of the formula.

However I am still facing a problem.

- Cell C8 sometimes has data (a date) sometimes it is blank.
- Cells W16:18 are intentionally left blank to manually add dates if needed.
-- When C8 is blank it matches with W16:18 and gives me a wrong result ("Αργία" instead of "").

Any bypass for that?
Try adding an AND condition, making sure C8 is not blank, i.e.
Excel Formula:
=IF(AND(C8<>"",COUNTIF(W3:W16,C8)>0),...)
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
15,444
Office Version
  1. 2013
Platform
  1. Windows
When C8 is blank

varios 23nov2021.xlsm
D
8Ρεπό
Hoja5
Cell Formulas
RangeFormula
D8D8=IF(C8="","",IF(COUNTIF($W$3:$W$18,C8),"Αργία", IF(COUNTIF($N$3:$N$25,C8),$C$39, IF(COUNTIF($O$3:$O$25,C8),"Ρεπό", IF(COUNTIF($P$3:$P$25,C8),"Κανονική", IF(COUNTIF($Q$3:$Q$25,C8),"Γονική", $B$39))))))
 

Lux Aeterna

Board Regular
Joined
Aug 27, 2015
Messages
114
Office Version
  1. 2019
Platform
  1. Windows
Codes didn't work, because they cause a conflict with the blank cells in columns N, O, etc. What worked for me was to add =IF(C8="";"";IF(COUNTIF($W$3:$W$18;C8);"Αργία" at the beginning. Its been working well so far. Thanks everyone for your help!
 

Forum statistics

Threads
1,182,105
Messages
5,933,665
Members
436,905
Latest member
Ibraeh

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
Top