IF statement

EvoUK

New Member
Joined
Jul 1, 2022
Messages
20
Office Version
  1. 365
Platform
  1. Windows
Hi,

I am currently using the formula below to select timings from various tables (arranged by day) based on the current date E3 and current time B1.
Using the current time, the formula correctly identifies the next timing event within the relevant day table.

However, the issue I am experiencing is that towards the end of the day (eg 23:59), there may not be any further times for that particular day within the table and the formula will then present #N/A. The next time could be 00:00 but this will of course be within the table for the following day and as such, will not be picked up by the formula until we reach the next day.

As a possible workaround, I was I considering adding another date field which will always display the date for the following day F3.

Is there a way the formula could be modified so that in the event of no further data being found within that table, instead of using WEEKDAY(E3,2), the formula will use (WEEKDAY(F3,2) forcing the formula to pick the next nearest time from the table for the following day?

Excel Formula:
=IF(WEEKDAY(E3,2)=1,XLOOKUP($E$6+1/86400,data_occ2pad2STP!$C$4:$C$52,data_occ2pad2STP!$C$4:$C$52,"not found",1), IF(WEEKDAY(E3,2)=2,XLOOKUP($E$6+1/86400,data_occ2pad2STP!$I$4:$I$52,data_occ2pad2STP!$I$4:$I$52,"not found",1), IF(WEEKDAY(E3,2)=3,XLOOKUP($E$6+1/86400,data_occ2pad2STP!$O$4:$O$52,data_occ2pad2STP!$O$4:$O$52,"not found",1), IF(WEEKDAY(E3,2)=4,XLOOKUP($E$6+1/86400,data_occ2pad2STP!$U$4:$U$52,data_occ2pad2STP!$U$4:$U$52,"not found",1), IF(WEEKDAY(E3,2)=5,XLOOKUP($E$6+1/86400,data_occ2pad2STP!$AA$4:$AA$52,data_occ2pad2STP!$AA$4:$AA$52,"not found",1), IF(WEEKDAY(E3,2)=6,XLOOKUP($E$6+1/86400,data_occ2pad2STP!$AG$4:$AG$52,data_occ2pad2STP!$AG$4:$AG$52,"not found",1), IF(WEEKDAY(E3,2)=7,XLOOKUP($E$6+1/86400,data_occ2pad2STP!$AM$4:$AM$52,data_occ2pad2STP!$AM$4:$AM$52,"not found",1))))))))

thanks
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
If your situation only produces the #N/A error in this situation, and this situation is the only time you would use F3 instead of E3, you could always nest your if statement into an iferror statement.

=IFERROR(your original statement , your modified statement)
 
Upvote 0

Forum statistics

Threads
1,215,076
Messages
6,122,987
Members
449,093
Latest member
Mr Hughes

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