Help With a Formula

MSF

New Member
Joined
Jan 2, 2023
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hello!

Given this formula:

=IF(OR(HOUR(AN2)+INT(AN2)*24 < 120, AND(HOUR(AN2)+INT(AN2)*24 = 0, MINUTE(AN2)+INT(AN2)*60 = 0, SECOND(AN2)+INT(AN2)*60 < 60)), IF(((100*(AN2/$AP$2))-100)/100 <> -1, ((100*(AN2/$AP$2))-100)/100, 0), "INVALID")

Essentially, if the time entered is 120 hours or greater, or is 59 seconds or less, the cell should display "INVALID".

But a time of 0:00:02 is not displaying "INVALID".

I can't seem to figure out why. Any suggestions?
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
MrExcelPlayground15.xlsx
GH
18121:00:00INVALID
1910:00:00 
200:00:58INVALID
210:01:00 
Sheet9
Cell Formulas
RangeFormula
H18:H21H18=IF(OR(G18>5,G18<1/60/24),"INVALID","")


"5" is 5 days, or 120 hours. the other one is a minute.
 
Upvote 0
Here is the correct formula
Excel Formula:
=IF(OR(HOUR(AN2)+INT(AN2)*24 >= 120, SECOND(AN2)+INT(AN2)*60 <= 59), "INVALID", 
 IF(((100*(AN2/$AP$2))-100)/100 <> -1, ((100*(AN2/$AP$2))-100)/100, 0))

This formula should correctly check whether the time entered in cell AN2 is greater than or equal to 120 hours, or less than or equal to 59 seconds, and if so, display "INVALID", otherwise it will calculate the value based on the ratio of AN2 to the value in cell AP2.
 
Upvote 0
Thanks for the help! Unfortunately, my own lack of attention and idiocy was the problem - the OR should have been AND.
 
Upvote 0
Solution

Forum statistics

Threads
1,214,919
Messages
6,122,259
Members
449,075
Latest member
staticfluids

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