Custom Function Within IF(AND(OR . . . Formula

DavidWF

Board Regular
Joined
Oct 14, 2015
Messages
130
I would like to create a custom function for use within an IF(AND(OR . . . formula, but I have no idea how to convert specific cell references into generic form or how to refer to cells in the preceding row, or in fact if what I'm trying to achieve is even practicable; maybe I've totally misunderstood the use of custom functions. As a last resort I can always just copy/paste the code block, but I'm hoping that a custom function would be neater.

The following block (within the outer brackets) has to be repeated several times within the formula in cell E2:
OR( AND(A1>A2,B1>B2,A1>B1), AND(A1>A2,B1<b2,a1>B2), AND(A1<a2,b1<b2,a2>B2), AND(A1<a2,b1>B2,A2>B1) )

Can that be made into a function and if so, how do I then use the function within the formula? For example, a simple version of the formula in cell E2 would be:
IF(AND(M2="RG",N2="Yes",OR( Custom function ) ),"Proceed","Hold")

Guidance on this will be much appreciated as I'm currently lost.</a2,b1></a2,b1<b2,a2></b2,a1>
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
to simplify things, if your criteria were and(A1=3,B1=7) or(C1=22,D1=33)
then in say cell Z1 you could put =if(and(A1=3,B1=7,or(C1=22,D1=33)),"proceed","hold")

you could then reference Z1 in your main formula
 
Upvote 0
Hi oldbrewer

Here it is again with spaces as requested. Thanks for that, I didn't realized it caused an issue.
The following block (within the outer brackets) has to be repeated several times within the formula in cell E2:
OR( AND(A1 > A2,B1 > B2,A1 > B1), AND(A1 > A2,B1 < B2,A1 > B2), AND(A1 < A2,B1 < B2,A2 > B2), AND(A1 < A2,B1 > B2,A2 > B1) )

I don't have specific numeric criteria; it's the relativity (greater than or less than) between the cells that's important.
 
Upvote 0
Whilst I'm not learning anything about custom functions, you are at least forcing me to re-think my fomulae, which is a positive.

The "simple version of the formula" was actually very simplified; this particular worksheet is unique in that I am testing against multiple criteria of which I only showed two instances. In this one cell I use that greater than / less than test against 5 other sets of criteria. Normally that comparison is only between two values, not between four, so it has necessitated a far more complex calculation. With your prompting, I can see now that for this particular sheet I need to reverse the logic sequence and make the greater than / less than test the first test, not the last one. That way, as you say, it only needs to appear once.

Thanks for stirring up the grey matter.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,244
Members
452,622
Latest member
Laura_PinksBTHFT

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