IF/AND formulas within excel

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi there,
Could anybody please help me with a formula i am trying to enter into my
excel spreadsheet.
i have two sets of variables "a" and "b" which are related to each other.
Using a seperate formula I obtain "c" What i would like to do is apply 1 of
4 equations to "c" depending on the value of "a" and "b".

if "a">0 and "b">0 then "c" stays as it is
"a"<0 and "b">0 then minus"c" from 360
"a">0 and "b"<0 then minus"c" from 180
"a"<0 and "b"<0 then "c" plus 180

Is it at all possible to formulate the above??

Thanks for any help


Mark
 
I suggest changing your variable names to va, vb,vc and then nesting the
if's
 
Hi mark,

See if this works:

A1 B1 C1
# # #

In D1 type
=IF(AND(A1>0,B1>0),C1,IF(AND(A1<0,B1>0),360-C1,IF(AND(A1>0,B1<0),180-C1,IF(AND(A1<0,B1<0),180+C1,"ERROR"))))

it worked for me.

HTH

cwilson
 
"a" "b" "c" are indicative only. I have true numerical values for them. What
i would like to do is enter a formula, that would have excel analyse cells
"va" and "vb" and then depending on the permutations of "va" and "vb" being
positive or negative, apply one of the equations. I have a couple hundred
sets of "va" and "vb" cells, so it would save alot of time, if it was
possible to enter a formula, rather than manually checking each set.
Is it possible to input one formula that contains all four equations below,
but that would only apply the correct one based on positives and negatives of
"va" and "vb"
 
First, what happens if "a"=0 or "b" = 0 ????

One way:

=IF(OR(a=0,b=0),"????",IF(a>0,IF(b>0,c,180-c),IF(b>0,360-c,c+180)))
 
Just another option:

=CHOOSE(2*(a>0)+(b>0)+1,c+180,360-c,180-c,c)

However, if a,b, & c are angles, then there may be a more simplified
solution.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top