String IF statement

PuntingJawa

Board Regular
Joined
Feb 25, 2021
Messages
140
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
I'm having trouble with an =If statement. If G4 is less than C3 then F4. But if G4 is greater than C3 then C4/G4. What I would like to add is if C3/G4 comes back with 0 or less than it returns as 0. Is there a way to go about this? I'm perfectly fine with any changes to formula.
My current statement
=IF(G4<C3,F4,IF(G4>C3,C3/G4)))
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Simple addition to your current formula:
Excel Formula:
=IF(G4<C3,F4,IF(G4>C3,MAX(C3/G4,0)))

BTW, you haven't accounted for the situation in with G4 and C3 are equal.
As you formula is currently written, it will return FALSE if that situation happens.
 
Upvote 1
That is a great point and something I overlooked. Thank you very much for your wisdom.
The formula is now =IF(G4<C3,G4,IF(G4>C3,MAX(C3/H4,0),IF(G4=C3,G4))) which should work nicely.
 
Upvote 0
That is a great point and something I overlooked. Thank you very much for your wisdom.
The formula is now =IF(G4<C3,G4,IF(G4>C3,MAX(C3/H4,0),IF(G4=C3,G4))) which should work nicely.
Actually, if it should G4 when then are equal, which is the same as when G4<C3, then you could simply that to:
Excel Formula:
=IF(G4<=C3,G4,IF(G4>C3,MAX(C3/H4,0)))

Or even shorter, since all possibilities are exhausted (i.e. if F4 is NOT <= C3, then it has to be > C3, so there is no need to explicitly check for that).
So you can get rid of the second IF like this:
Excel Formula:
=IF(G4<=C3,G4,MAX(C3/H4,0))
for the simpliest version yet!
 
Upvote 1
Solution
Even better. I can read the shorter must easier as well. Thank you again!
 
Upvote 0
You are welcome!
Glad I was able to help.
 
Upvote 0

Forum statistics

Threads
1,214,636
Messages
6,120,669
Members
448,977
Latest member
moonlight6

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
Back
Top