Nested IF formula with multiple criteria not working

CaptainGravyBum

New Member
Joined
Dec 1, 2023
Messages
46
Office Version
  1. 365
Platform
  1. Windows
OK, I've tried my best, but I just can't find out what is going on with this formula. Chat GPT is usually a little helpful, but even that is stumped - you can't beat good old fashioned brain power so I'm hoping you can help.

The link to my file is below, I'm trying to add a formula in column R of the upload template sheet which looks for various criteria to be met before providing a result - mainly because there is a lot of error checking due to the data being provided by various people who can make errors. I can get cell R2 to return 8:00 which is correct, but then everything else is false, as though it looks at the first IF and ignores all others. At the moment it's ignoring the cells which don't return a time which is what I want, but also returning false for the cells where there should be data.

=IFERROR(
IF('Vigo Data'!AF1=0,IF(AND((SEARCH("AM",Q2)), 'Vigo Data'!AF1 >= TIME(5, 0, 0), 'Vigo Data'!AF1 <= TIME(11, 59, 0)), 'Vigo Data'!AF1,"")&
IF('Vigo Data'!AF1=0,IF(AND((SEARCH("PM", Q2)), 'Vigo Data'!AF1 >= TIME(12, 1, 0), 'Vigo Data'!AF1 <= TIME(23, 59, 0)), 'Vigo Data'!AF1,"")&
IF('Vigo Data'!AF1=0,IF(AND((SEARCH("TIME", Q2)), 'Vigo Data'!AF1 >= TIME(0, 1, 0), 'Vigo Data'!AF1 <= TIME(23, 59, 0)), 'Vigo Data'!AF1,"")))),"")



 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Your conditions seem to be conflicting with each other. First, you are testing if 'Vigo Data'!AF1 is equal to 0. If it is, then you are testing if it is between two specific values.. which are both larger than 0.

So when the first IF is true, the rest will be false. Conversely, if the first IF is false, the rest could be true, but it won't even get there.
 
Upvote 0
I don't know if this solves the problem, but it makes sense to me (unable to download your sheet at work):

Excel Formula:
=IFERROR(IF('Vigo Data'!AF1>0,IF(AND(ISNUMBER(SEARCH("AM",Q2)), 'Vigo Data'!AF1 >= TIME(5, 0, 0), 'Vigo Data'!AF1 <= TIME(11, 59, 0)), 'Vigo Data'!AF1,"")&IF('Vigo Data'!AF1>0,IF(AND(ISNUMBER(SEARCH("PM", Q2)), 'Vigo Data'!AF1 >= TIME(12, 1, 0), 'Vigo Data'!AF1 <= TIME(23, 59, 0)), 'Vigo Data'!AF1,"")&IF('Vigo Data'!AF1>0,IF(AND(ISNUMBER(SEARCH("TIME", Q2)), 'Vigo Data'!AF1 >= TIME(0, 1, 0), 'Vigo Data'!AF1 <= TIME(23, 59, 0)), 'Vigo Data'!AF1,""),""),""),""),"")
 
Upvote 0
Hi @dreid1011,
Thanks for your reply. The first test is supposed to say, if the cell is greater than 0 although it doesn't seem to be working anyway. I think I need to reshuffle the formula a bit, because yours is returning results where there is a time already on the sheet, but If there isn't anything it should result in the manually entered time I have specified.
Weird thing is that the time on my upload sheet (from the formula result) is only showing a decimal and will not allow me to change it to any other format - bit confused why that would be happening.
 
Upvote 0
Hi @dreid1011,
Thanks for your reply. The first test is supposed to say, if the cell is greater than 0 although it doesn't seem to be working anyway. I think I need to reshuffle the formula a bit, because yours is returning results where there is a time already on the sheet, but If there isn't anything it should result in the manually entered time I have specified.
Weird thing is that the time on my upload sheet (from the formula result) is only showing a decimal and will not allow me to change it to any other format - bit confused why that would be happening.
If you can provide a small sample of data and the expected results, I'm sure we can come up with a solution.
 
Upvote 0
Not really sure how this XL2BB malarky works, but here is the main sheet it created:
Upload Copy.xlsm
U
10
Upload Template

Which references this sheet:
Upload Copy.xlsm
G
12
Vigo Data

Hope this helps, I did get it to return values for the first two rows, but it also returned the same value for the cells where there shouldn't be data - so that didn't work.
 
Upvote 0
You have to select the whole range of data before you create the mini sheet.
 
Upvote 0
Whoops, try again.
Upload Copy.xlsm
ABCDEFGHIJKLMNOPQR
1DocketOrder_NoDespatch DateRequesting DepotCollect DepotConsignor NameConsignorPostCodeConsignee NameConsignee Address 1Consignee Address 2Consignee Address 3Consignee Address 4Consignee PostcodeDelivery DepotTrunkServiceDelivery Time
2AM0.333333333333333
3PM0.583333333333333
4TIME11:00
5ND11:00
6EC11:00
7ND11:00
8ND11:00
Upload Template
Cell Formulas
RangeFormula
Q2:Q8Q2=VLOOKUP('Vigo Data'!AD1,Instructions!Z:AB,3,0)
R2:R8R2=IFERROR(IF('Vigo Data'!AF1>0,IF(AND(ISNUMBER(SEARCH("AM",Q2)), 'Vigo Data'!AF1 >= TIME(5, 0, 0), 'Vigo Data'!AF1 <= TIME(11, 59, 0)), 'Vigo Data'!AF1,"")&IF('Vigo Data'!AF1>0,IF(AND(ISNUMBER(SEARCH("PM", Q2)), 'Vigo Data'!AF1 >= TIME(12, 1, 0), 'Vigo Data'!AF1 <= TIME(23, 59, 0)), 'Vigo Data'!AF1,"")&IF('Vigo Data'!AF1>0,IF(AND(ISNUMBER(SEARCH("TIME", Q2)), 'Vigo Data'!AF1 >= TIME(0, 1, 0), 'Vigo Data'!AF1 <= TIME(23, 59, 0)), 'Vigo Data'!AF1,""),"10:00"),"14:00"),"11:00"),"")
Cells with Conditional Formatting
CellConditionCell FormatStop If True
R1:R3,R5:R1048576,R4:S4Cell Value="ENTER TIME"textNO



Upload Copy.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAF
1GB24A26/02/202408:00
2GB24P26/02/202414:00
3GB24T26/02/2024
4GB2426/02/2024
5GB4827/02/2024
6GB2426/02/2024
7GB2426/02/2024
Vigo Data
 
Upvote 0
Another note, you don't have to select from A1 to your data, you could also just select AC1:AF7 since that seems to be the relevant section. But now I can see what to work with better. Thank you.
 
Upvote 0
Another note, you don't have to select from A1 to your data, you could also just select AC1:AF7 since that seems to be the relevant section. But now I can see what to work with better. Thank you.
Yeah, that was just to make sure the columns where the correct letters.
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,959
Members
449,096
Latest member
Anshu121

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