Debugging an "IF" formula

DarkSmile

Board Regular
Joined
Feb 22, 2021
Messages
90
Office Version
  1. 365
Platform
  1. Windows
Hallo,

I'm back with another question.. I will try my best to explain what I'm doing.

I got a file with multiple sheets, on sheet1 (called Food) I have a button with the following code:
VBA Code:
Sub Alles_Aangeduid()
  Sheets("ACS-002").Range("A3:B15").Copy Destination:=Sheets("Food").Range("A13")
End Sub

This script copies specific cells from sheet2 (called ACS-002) to sheet one (Food)
It's also copying cells with formulas, but whenever I change value (run the formula) it gives me an error.. Can someone help me debug de error?

Here both formulas, B14 is on purpose not locked, because it's not the same cell in Sheet1 & 2.
Excel Formula:
=IF(B14="Ja",IF('ACS-002'!$B$28,'ACS-002'!$D$41,IF('ACS-002'!$B$29,'ACS-002'!$D$42,IF('ACS-002'!$B$30,'ACS-002'!$D$43,IF('ACS-002'!$B$31,'ACS-002'!$D$44,"ERROR")))))

=IF(B14="Nee",IF('ACS-002'!$B$28,'ACS-002'!$B$41,IF('ACS-002'!$B$29,'ACS-002'!$B$42,IF('ACS-002'!$B$30,'ACS-002'!$B$43,IF('ACS-002'!$B$31,'ACS-002'!$B$44,"ERROR")))))

When changing a value it gives me the "ERROR" (= FALSE) It shouldn't give error but a value.
1614170536863.png

1614170548687.png


TCA berekening.xlsm
ABC
12
13Parameters : ACS-002 Ind Lait
14Klein bedrijf?
15Aantal Producttypes:
16Producttypes:
17Productstromen naar de dierenvoeding?:
18
19Aantal Producttypes:0
20Klein bedrijfFALSE
21Normaal bedrijfFALSE
22Dierenvoeders0
23Totaal klein0
24Totaal normaal0
25Totaal auditduur:0
26
Food
Cell Formulas
RangeFormula
B19B19=B15
B20B20=IF(B14="Ja",IF('ACS-002'!$B$28,'ACS-002'!$D$41,IF('ACS-002'!$B$29,'ACS-002'!$D$42,IF('ACS-002'!$B$30,'ACS-002'!$D$43,IF('ACS-002'!$B$31,'ACS-002'!$D$44,"ERROR")))))
B21B21=IF(B14="Nee",IF('ACS-002'!$B$28,'ACS-002'!$B$41,IF('ACS-002'!$B$29,'ACS-002'!$B$42,IF('ACS-002'!$B$30,'ACS-002'!$B$43,IF('ACS-002'!$B$31,'ACS-002'!$B$44,"ERROR")))))
B22B22=IF(B17="Ja",'ACS-002'!$A$46,)
B23B23=IF(B20<>FALSE,B20+B22,0)
B24B24=IF(B21<>FALSE,B21+B22,0)
B25B25=SUM(B23:B24)
Cells with Data Validation
CellAllowCriteria
B14List=KleinBedrijf
B15List=Aantal
B16List=Producttypes
B17List=Dierenvoeders


TCA berekening.xlsm
ABCDE
1Benodigde parameters
2
3Parameters : ACS-002 Ind Lait
4Klein bedrijf?
5Aantal Producttypes:
6Producttypes:
7Productstromen naar de dierenvoeding?:
8
9Aantal Producttypes:0
10Klein bedrijfFALSE
11Normaal bedrijfFALSE
12Dierenvoeders0
13Totaal klein0
14Totaal normaal0
15Totaal auditduur:0
16
17
18
19
20
21Dropdown list: Klein bedrijfDropdown list: AantalDropdown list: ProducttypesDropdown list: Dierenvoeders
22Ja1UHT-consumptiemelkdranken en UHT- roomJa
23Nee2Gesteriliseerde consumptiemelkdranken en roomNee
243Gepasteuriseerde consumptiemelkdranken en room
254 of meerGefermenteerde melk
26Thermisch behandelde gefermenteerde melk
27Verse kaas
28!=B9=B22FALSEHarde kaas op basis van gepasteuriseerde melk
29!=B9=B23FALSEMozzarella op basis van gepasteuriseerde melk
30!=B9=B24FALSEZachte kaas op basis van gepasteuriseerde melk
31!=B9=B25FALSEZure boter op basis van gepasteuriseerde melk, verse zure karnemelk, thermisch behandelde zure karnemelk
32Melkpoeder
33Neutrale desserts
34Rauwmelkse kazen
35Zure boter op basis van rauwe melk en verse zure karnemelk
36
37
38
39Normaalsmall enterprise
40Aantal producttypesTe besteden mandagen (uren)Aantal producttypesTe besteden mandagen (uren)
4111014
4221226
4331438
444 of meer164 of meer10
45Dierenvoeders (uren)
462
47
ACS-002
Cell Formulas
RangeFormula
B9B9=B5
B10B10=IF(B4="Ja",IF('ACS-002'!$B$28,'ACS-002'!$D$41,IF('ACS-002'!$B$29,'ACS-002'!$D$42,IF('ACS-002'!$B$30,'ACS-002'!$D$43,IF('ACS-002'!$B$31,'ACS-002'!$D$44,"ERROR")))))
B11B11=IF(B4="Nee",IF('ACS-002'!$B$28,'ACS-002'!$B$41,IF('ACS-002'!$B$29,'ACS-002'!$B$42,IF('ACS-002'!$B$30,'ACS-002'!$B$43,IF('ACS-002'!$B$31,'ACS-002'!$B$44,"ERROR")))))
B12B12=IF(B7="Ja",'ACS-002'!$A$46,)
B13B13=IF(B10<>FALSE,B10+B12,0)
B14B14=IF(B11<>FALSE,B11+B12,0)
B15B15=SUM(B13:B14)
B28B28=B9=B22
B29B29=B9=B23
B30B30=B9=B24
B31B31=B9=B25
Named Ranges
NameRefers ToCells
Aantal='ACS-002'!$B$22:$B$25B28
Cells with Data Validation
CellAllowCriteria
B4List=KleinBedrijf
B5List=Aantal
B6List=Producttypes
B7List=Dierenvoeders
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
=IF(B14="Ja",IF('ACS-002'!$B$28,'ACS-002'!$D$41,IF('ACS-002'!$B$29,'ACS-002'!$D$42,IF('ACS-002'!$B$30,'ACS-002'!$D$43,IF('ACS-002'!$B$31,'ACS-002'!$D$44,"ERROR")))),"")
 
Upvote 0
What do you mean with breaks? The formulas are simular to ACS-002. When filled all the data (B16-B19) the formulas are working.
 
Upvote 0
See printscreens down beneath: when using your formula in sheet ACS-002 it gives this:
1614177793123.png


However, when using the copy button (to copy cells to sheet Food) it gives this
1614177850685.png


It's like the formula can't search for the needed parameters on the other sheet? Note: Sheet ACS-002 will be hidden so it needs to be able to calculate in sheet Food (ACS-002 is a placeholder)
 
Upvote 0
What wrong is. On ACS-002 are the cells B28-B31 dependent from cell B5.
When you change on FEED cell B17 then it would nothing change because B28-B31 are unchanged.
 
Upvote 0
Change your formula in cell B10 for searching UREN with VLOOKUP(B9,'ACS-002'!$C$41:$D$44,2,FALSE)
 
Upvote 0
Solution
Change your formula in cell B10 for searching UREN with VLOOKUP(B9,'ACS-002'!$C$41:$D$44,2,FALSE)
This one works, it just needed a little tweaking. Changed it to

(first one B10, second one B11)
Excel Formula:
=IF(B4="Ja",VLOOKUP(B9,'ACS-002'!$C$41:$D$44,2,FALSE))
=IF(B4="Nee",VLOOKUP(B9,'ACS-002'!$A$41:$B$44,2,FALSE))
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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