Complex if/iferror formula

RattlingCarp3048

Board Regular
Joined
Jan 12, 2022
Messages
166
Office Version
  1. 365
Platform
  1. Windows
HELP... i need to make a formula that is a bit more complex than I am used to. if there is a much simpler way than my initial approach i am open to alternative methods.

Columns F, H, and N each contain their own formula. They either result in a number or a "-" as a result of an error.

I need Column P to = F+H+N.

If Column B = "IHC" then calculate F+(H*3)+N instead.

If any one or combination of F, H, or N = "-" calculate the others instead. For instance

If B = IHC then calculate F+H*3+N otherwise calculate base

If B = IHC then calculate F+H*3+N

If F = - then calculate H+N

If H = - then calculate F+N

If N = - then calculate F+H

If F+H = - then calculate N

If F+N = - then calculate H

If H+N= - then calculate F

If B = IHC then calculate H+N

If B = IHC then calculate H+N etc...
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
See if this works. In theory it should but I haven't tested it.
Excel Formula:
=SUM(F2,PRODUCT(H2,IF(B2="IHC",3,1)),N2)
 
Upvote 0
Hi RattlingCarp3408,

I'm finding it tricky following the requirement but aren't you just treating the "-" as if it's a zero?

RattlingCarp3048.xlsx
BFHNP
1IHC22210
2IHC12310
3IHC-217
4IHC1-78
5IHC11-4
62226
71236
8-213
91-78
1011-2
Sheet1
Cell Formulas
RangeFormula
F3,N10,H9,F8,N5,H4F3="-"
P1:P10P1=IF(B1="IHC",(N(F1)+(N(H1)*3)+N(N1)),(N(F1)+N(H1)+N(N1)))
 
Upvote 0
How about:

varios 28ene2022.xlsm
BFHNP
1
2IHC22210
3IHC12310
4IHC-217
5IHC1-78
6IHC11-4
72226
81236
9-213
101-78
1111-2
Hoja20
Cell Formulas
RangeFormula
P2:P11P2=SUM(F2,N(H2)*IF(B2="IHC",3,1),N2)
 
Last edited:
Upvote 0
Sorry I wasnt more clear. Here is a sample picture of data. Names and titles changed for confidentiality. F,H,N are different departments. Each employee has a primary department they are assigned to but some are cross-trained to work in other areas. so the data per person is constantly changing between the columns. Basically what i am trying to do is add the columns that do have data and ignore the ones that are "-". The dashes do not represent 0. Columns F, H, N each have their own individual formulas in them that state if the return value is 0 or error, show a dash instead. This is just to help keep the sheet cleaner in appearance.

1643416481912.png
 
Upvote 0
Does this give you what you want?

Book1.xlsx
BFHNP
1
2IHC-40-120
3Meat32.0--32
4Veggies-15-15
5IHC23.03412137
6Veggies1515
7Veggies243256
Sheet1
Cell Formulas
RangeFormula
P2:P7P2=IF(B2="IHC",(H2*3)+SUM(F2)+SUM(N2),SUM(F2)+SUM(H2)+SUM(N2))
 
Upvote 0
Does this give you what you want?

Book1.xlsx
BFHNP
1
2IHC-40-120
3Meat32.0--32
4Veggies-15-15
5IHC23.03412137
6Veggies1515
7Veggies243256
Sheet1
Cell Formulas
RangeFormula
P2:P7P2=IF(B2="IHC",(H2*3)+SUM(F2)+SUM(N2),SUM(F2)+SUM(H2)+SUM(N2))
=IF(B2="IHC",(H2*3)+SUM(F2)+SUM(N2),SUM(F2)+SUM(H2)+SUM(N2))

This that you gave is the closest ive been all day. in about 98% of the rows it is working perfectly. What I dont understand is the instances where it didnt. I double checked that the formulas in the columns are the same all the way down and basic formatting of the cells is the same. so why would this be happening.... why the #value! error?

1643419088085.png
 
Upvote 0
Does this give you what you want?

Book1.xlsx
BFHNP
1
2IHC-40-120
3Meat32.0--32
4Veggies-15-15
5IHC23.03412137
6Veggies1515
7Veggies243256
Sheet1
Cell Formulas
RangeFormula
P2:P7P2=IF(B2="IHC",(H2*3)+SUM(F2)+SUM(N2),SUM(F2)+SUM(H2)+SUM(N2))
oh i see.... its because of this... its trying to multiply H*3 when there is no data in H because B=IHC.

1643419294428.png
 
Upvote 0
oh i see.... its because of this... its trying to multiply H*3 when there is no data in H because B=IHC.

View attachment 56410
Understood. Try this instead

Book1.xlsx
BFHNP
1
2IHC---0
3Meat32.0--32
4Veggies-15-15
5IHC23.03412137
6Veggies1515
7Veggies243256
Sheet1
Cell Formulas
RangeFormula
P2:P7P2=IF(AND(B2="IHC",ISNUMBER(H2)),(H2*3)+SUM(F2)+SUM(N2),SUM(F2)+SUM(H2)+SUM(N2))
 
Upvote 0
Solution

Forum statistics

Threads
1,214,833
Messages
6,121,868
Members
449,053
Latest member
Mesh

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