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!

-

migrated from stackoverflow.comNov 18 '12 at 15:07

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

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

``````=IF(A3<=A1,"Within budget","Over budget by \$"&(A3-A1))
``````
-
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
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
Rick, posting virtually identical answers to earlier posts doesn't aid the community –  brettdj Nov 18 '12 at 11:58
``````=IF(A3>A1,"Over budget by \$ " &(A3-A1),"")
``````
-
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
@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