if-or-and question

wpryan

Well-known Member
Joined
May 26, 2009
Messages
534
Office Version
  1. 365
Platform
  1. Windows
I'm trying to get a formula to work:
What it's intended to do is, if the values of G8 and G7 are the same, and the value of I9 is less than I7, then to calculate the difference of I7 from I9 and to add the value of I6. If the values of G8 and G7 are the same and the value of I9 is greater than I7, to subtract 4000 from I9 and add I6. The last condition is to simply put the value 0 as the result. I can't seem to get this to work... I tried to put the code in the message text but the system is stripping out half of it! It seems that the system doesn't like the "greater than" or "less than" symbols... I'll try it this way:

Code:
=IF(OR(AND(G8=G7,I9"less than"I7)),I7-I9+I6,IF(OR(AND(G8=G7,I9"greater than"I7)),4000-I9+I6,0))
Thanks in advance.
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
This will do the following.

If G8 is the same as G7 AND I9 is less than I7
Then Subtract I9 from I7 and add I6

If G8 is the same as G7 AND I9 is greater than I7
Then subtract I9 from 4000 and add I6

If G8 does not equal G7, or if I9 equals I7,
Then 0

=IF(AND(G8=G7,I9<I7),I7-I9+I6,IF(AND(G8=G7,I9>I7),4000-I9+I6,0))
 
Upvote 0
this one worked for me just fine.

=IF(AND(G7=G8,I9<I7),(I7-I9),IF(AND(G7=G8,I9>I7),(I9-4000)+I7,))
 
Upvote 0
For less than signs, they get interpreted as HTML, so you should write &*l*t*;
Likewise, greater than signs should be written as &*g*t*;

(Remove the *)
 
Upvote 0
Alternatively, you can just put a space after the < sign, like this

=IF(AND(G7=G8,I9< I7),(I7-I9),IF(AND(G7=G8,I9>I7),(I9-4000)+I7,))

Also, following your 'Report' I have removed some of those failed posts.
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,827
Members
452,946
Latest member
JoseDavid

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