multiple if conditions

naciovica

New Member
Joined
Feb 4, 2019
Messages
4
Good day!
i have a table with 4 columns.
col1 col2 col3 col4
Please help me with a formula that outputs the following:
col1=empty & col2=empty & col3=empty & col4=empty => output a
col1>0 & col2=empty & col3=empty & col4=empty => output b
col1>0 & col2>0 & col3=empty & col4=empty => output c
col1>0 & col2>0 & col3>0 & col4=empty => output d
col1>0 & col2>0 & col3>0 & col4>0 => output e
i've tried all the if/and and if/or formulas but i don't find the solution.
Thanks in advance.
Have a nice day!
 

KennyGreens

Board Regular
Joined
Aug 8, 2018
Messages
142
Hi there, try something like this:

=IF(AND(A2=0, B2=0, C2=0, D2=0), "a", IF(AND(A2>0, B2=0, C2=0, D2=0), "b", IF(AND(A2>0, B2>0, C2=0, D2=0), "c", IF(AND(A2>0, B2>0, C2>0, D2=0), "d", IF(AND(A2>0, B2>0, C2>0, D2>0), "e", "")))))
 

bobsan42

Well-known Member
Joined
Jul 14, 2010
Messages
1,283
What happens if values are less or equal to 0???
Normally you could use nested IFs. But here you present 5 cases, while there is total of 2^4=16 possible combinations (excluding possibilities for 0 and negative numbers).
The simplest way to achieve what you presented IMO is:

Code:
=IF(AND(ISBLANK(col1),ISBLANK(col2),ISBLANK(col3),ISBLANK(col4)),output a,
IF(AND(col1>0,ISBLANK(col2),ISBLANK(col3),ISBLANK(col4)),output b,
IF(AND(col1>0,col2>0,ISBLANK(col3),ISBLANK(col4)),output c,
IF(AND(col1>0,col2>0,col3>0,ISBLANK(col4)),output d,
IF(AND(col1>0,col2>0,col3>0,col4>0),output e)
))))
This must all go in a single line formula. However there are a lot of possibilities unaccounted for - in these cases the formula will evaluate to FALSE.
 

naciovica

New Member
Joined
Feb 4, 2019
Messages
4
thanks. this worded. i added one more condition to have an output of empty cell.
 

Forum statistics

Threads
1,081,676
Messages
5,360,441
Members
400,586
Latest member
Minty

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top