Apply IF Statement on each cell in specified range

Mr_Patrick

New Member
Joined
Feb 24, 2017
Messages
8
Hi everyone,

I am trying to define a formula which takes the product of a specified range, where, if the value of any cell (taken individually!) happens to be between (-1,1), then the function will first take the inverse of those values before multiplying every value together. The function is also told to ignore zero values.

For example, if I have
[TABLE="width: 200"]
<tbody>[TR]
[TD]2
[/TD]
[TD]0.4
[/TD]
[TD][/TD]
[TD]1
[/TD]
[TD]-0.9
[/TD]
[/TR]
</tbody>[/TABLE]

then I wish my function to calculate : 2*(1/0.4)*1*(1/-0.9)
I have tried something like :

{=PRODUCT(IF(A1:E1<>0;IF(AND(-1<=A1:E1;A1:E1<=1);1/A1:E1;A1:E1)))<B5:i5;b5:i5<1);1 B5:I5;B5:I5)))
}
<B5:i5;b5:i5<1);1 A1:E1;A1:E1)))

<B5:i5;b5:i5<1);1 B5:I5;B5:I5)))}
The above function correctly ignores zero valued cells, but I noticed that the argument of PRODUCT is either be the whole A1:E1 or each of its values inverted.
I would like the function to check each cell individually and apply the inversion when the condition is met, before patching up the values and feeding them to the Product function
<B5:i5;b5:i5<1);1 B5:I5;B5:I5)))
Can someone help me out?
<B5:i5;b5:i5<1);1 B5:I5;B5:I5)))

Thank you in advance.</B5:i5;b5:i5<1);1></B5:i5;b5:i5<1);1></B5:i5;b5:i5<1);1></B5:i5;b5:i5<1);1></B5:i5;b5:i5<1);1>
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Hi, welcome to the forum!

You can't use the AND() function like that in array formula, here is one possible alternative.

{=PRODUCT(IF(A1:E1<>0,IF((A1:E1<1)*(A1:E1>-1),1/A1:E1,A1:E1)))}
 
Upvote 0
Try the following array formula (to be entered using Ctrl+Shift+Enter, not just Enter):

=PRODUCT(IF((ABS(A1:D1)<=1)*(A1:D1<>0),1/A1:D1,A1:D1))
 
Upvote 0
Amazing thank you a lot! Both suggestions are what I was looking for!

I see that I still have a lot to learn in Excel.
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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