Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm looking to write an Excel IF statement that does the following

If cell A3 is over budget A1, print text "Over Budget by $" and then Sum(a3-a1)

so, the result should look like:

Over budget by $27

Does anyone know how I can achieve this?

Thanks!

share|improve this question

migrated from stackoverflow.com Nov 18 '12 at 15:07

This question came from our site for professional and enthusiast programmers.

add comment

2 Answers 2

up vote 0 down vote accepted

http://office.microsoft.com/en-us/excel-help/if-HP005209118.aspx

=IF(A3<=A1,"Within budget","Over budget by $"&(A3-A1))
share|improve this answer
    
Hoang has provided the same answer already –  brettdj Nov 18 '12 at 4:50
    
Thanks Rick! any idea how to also add a third layer, and have it that if the a3=a1, print text "Budget Balanced" –  user1833002 Nov 18 '12 at 5:00
2  
You need a nested function. Each if statement has the following logic =if(operation to test,if true do this, if false do this). So if you want more layers nest another function into the statement.=if(operation to test, if true do this, if false test another operation. So in your case =IF(A3>A1,"Over budget by $"&(A3-A1),IF(A3<A1, "Under budget by $"&(A1-A3), IF(A3=A1, "Balanced Budget",""))) –  Rick Nov 18 '12 at 5:28
1  
Rick, posting virtually identical answers to earlier posts doesn't aid the community –  brettdj Nov 18 '12 at 11:58
add comment
=IF(A3>A1,"Over budget by $ " &(A3-A1),"")
share|improve this answer
    
awesome, thanks.. any idea how to also add a third layer, and have it that if the a3=a1, print text "Budget Balanced" –  user1833002 Nov 18 '12 at 4:53
4  
@user1833002 =IF(A1=A3,"Budget balanced",IF(A3<A1,"Within budget","Over budget by $ "&(A3-A1))) (posted as a comment as Hoang deserves the accept points) –  brettdj Nov 18 '12 at 5:02
    
THANKYOU! WORKS GREAT! –  user1833002 Nov 18 '12 at 5:09
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.