If Statement - Multiple Criteria

spyldbrat

Board Regular
Joined
May 5, 2002
Messages
211
Office Version
  1. 365
I have 3 columns: Start Time, Pro Clock In, Ram Clock In. I am trying to find out the # of actual minutes there are between the two clock in's. However, there are few exceptions to the calculating the minutes.

Column H (Start Time)
Column J (Pro Clock In)
Column Q (Ram Clock in)

if Q = J, then the result would be nothing (or blank)
if J is earlier than Q, then the result would be nothing
if Q is earlier than H, then I want to subtract J from H BUT if J is earlier than J return the result of nothing
if Q is later than H, I want to subtract Q, then subtract Q from J

1601664662815.png


Thanks.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Error in this statement:
if Q is earlier than H, then I want to subtract J from H BUT if J is earlier than J return the result of nothing

Can you clarify that?
 
Upvote 0
Sorry:

if Q is earlier than H, then I want to subtract J from H BUT if J is earlier than H return the result of nothing
 
Upvote 0
I'll try to figure something out, but the last statement is a bit hard. you expect two end results, so I'm not sure if what I come up with will work. Code below color coded for better codiness.


if Q = J, then the result would be nothing (or blank)
if J is earlier than Q, then the result would be nothing

if Q is earlier than H, then I want to subtract J from H BUT if J is earlier than J return the result of nothing - Please correct. code below assumes first J should be H
if Q is later than H, I want to subtract Q, then subtract Q from J - Please correct. Substract Q from H?

Not sure where you want the values to be displayed. I'm guessing you want the value to spit out in a single cell. Otherwise, it seems like you want to do a bunch of circular references and that'd be bad, mkay?

=IF(OR(Q9 = J9, J9 < Q9), "", If(Q9<H9, If(H9<J9, "", H9-J9), if(Q9>H9, (H9-Q9)+(J9-Q9), "I Screwed Something Up")))
 
Upvote 0
Does this do what you are looking for?
Excel Formula:
=IF(OR(J7<=Q7,J7<H7),"",IF(Q7<H7,H7-J7,J7-Q7))
Note that you did not indicate what should happen if column Q equals column H.
 
Upvote 0
Oh, I see what you're saying...(It's been a long day!!! Sorry!)

if Q is later than H, I want to subtract Q from J
 
Upvote 0
Oh, I see what you're saying...(It's been a long day!!! Sorry!)

if Q is later than H, I want to subtract Q from J


Gotcha!

=IF(OR(Q9 = J9, J9 < Q9), "", If(Q9<H9, If(H9<J9, "", H9-J9), if(Q9>H9, J9-Q9, "I Screwed Something Up")))
 
Upvote 0

Forum statistics

Threads
1,215,231
Messages
6,123,754
Members
449,119
Latest member
moudenourd

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