Trim down an excel formula? - excel

Hey I'm trying to get my excel formula to fit in to a data validation formula, which after a little research I'm finding has a 255 character limit. Mine has 277 characters, and I feel like it's got some redundancies, but I'm not advanced enough to figure out how to trim this heffer down. Can anyone out there help?
=IF(AND(H11="Embryo",G11<>"F2"),INDIRECT("'"&C11&"'"&"!$g$24:$g$27"),IF(AND(H11="Seed",G11<>"F2"),INDIRECT("'"&C11&"'"&"!$h$24:$h$27"),IF(AND(H11="Seed",G11="F2"),INDIRECT("'"&C11&"'"&"!$g$117:$g$120"),IF(AND(H11="Embryo",G11="F2"),INDIRECT("'"&C11&"'"&"!$h$117:$h$120"),E2))))

As you always include the cell C11 inside an INDIRECT please consider the following formula that places the INDIRECT outside while the conditionals just return the range addresses as strings.
=INDIRECT("'"&C11&"'"&IF(AND(H11="Embryo",G11<>"F2"),"!$g$24:$g$27",IF(AND(H11="Seed",G11<>"F2"),"!$h$24:$h$27",IF(AND(H11="Seed",G11="F2"),"!$g$117:$g$120",IF(AND(H11="Embryo",G11="F2"),"!$h$117:$h$120",E2)))))
Please note that this logic will break if none of the conditions are met. Regards,

I'd suggest taking some of the parts of your formula and defining names for those regions of your sheet this way you can condense long strings into small words greatly reducing the length of your formula. Could help a great deal. Also will make your formula more readable to you down the road when you find yourself having to debug it.

Related

Dynamic Countif when data range is letters

I have Data range full of letters and want a dynamic count in excel when a filter is applied.
I used following formula for numbers
=SUMPRODUCT(SUBTOTAL(3, OFFSET($FW$40:$FW$144, ROW($FW$40:$FW$144)-MIN(ROW($FW$40:$FW$144)),,1)), ISNUMBER(SEARCH(1,$FW$40:$FW$144))+0)
I thought of changing the last part to look for a text e.g."A" would work but unfortunately it doesn't work.
Can somebody show me a formula on how I can do this when my data is all letters?
Thanks in advance!
After a lot of reading I worked out you can use -- to search for text.
My formula works... Thanks

EXCEL: SUMIF In Array Formula Causing Errors

I have noticed that SUMIF does not play nice with array formulas.
To save on convoluted explanations of my motivation, here is a sample that demonstrates the issue:
=SUMIF(ROW(INDIRECT("1:10")),"<5")
My current work around would be:
=SUM(ROW(INDIRECT("1:10"))*IF(ROW(INDIRECT("1:10"))<5,1,0))
But my actual formula is quite lengthy and I don't want to repeat the criteria in both places.
Can anyone help me understand what's going on?
Thank you

inequality in COUNTIF (excel)

I am trying to count the cells in a continuous range if they are less than or equal to a variable, referenced from another cell. It seems very close to this,
COUNTIF(A4:A20,">=32")
But I want the 32 replaced with a variable, A3. I have not seen an example of that yet. Would be grateful if someone would help me with the formatting. Thanks!
You just about have it, switch to:
=COUNTIF(A4:A20,">="&A3)

VBA FormulaR1C1 RC expression is not working when used with division

I am new to vba. I try to put a formula into a range which works well, but the formula is troubling me. I feel the issue might be because of the division.. maybe the slash is a kind of escaping character?
Here the code:
MyWorksheet.Range("J7","J12").FormulaR1C1 = "=R[0]C[-1]/R0C1 *100"
and it gives me this in excel:
=I7/R0C1 *100
So R0C1 is not replaced :-(. How comes? and how can I fix this?
I have goggled a lot but I did not find anything similar.. so hopefully I am not the only one with this issue.
Any help is highly appreciated!
Best regards,
Tobias
Your problem is the zero in your formula - when using absolute reference (i.e. omitting brackets) in R1C1-notation, you count from an imaginary cell one up and one left of A1 - in other words, cell A1 is R1C1 in that notation, B2 is R2C2, etc.
And R0C1 does not exist, thus why it is interpreted as a string in your formula.

IF statements combining multiple columns

I am using excel 2010 and looking to use IF statements to add multiple columns that have both letters and numbers. I have come as far as to get all the coding in so that when one of each condition is presented they total correctly.
The problem I am having is if there is more than one of the same condition.
For example the IF statement I am using is: =IF(ISNA(MATCH("1P",C7:CO7,0)),0,1)+IF(ISNA(MATCH("2P",C7:CO7,0)),0,2) and so on.
Obviously between cells C7 and CO7 there are many cells and if more than one cell has 1P or 2P in it the additional cells are not being added and only one. How can I get my formula to recognize the condition in more than one cell?
Thanks
=COUNTIF(C7:CO7,"1P")+2*COUNTIF(C7:CO7,"2P") should get you the answer you need
Edit: Fixed formula - thanks #Andy
If you are interested in a flexible approach that allows for an arbitrary number of match values and multipliers, you could try this.
Make a little table somewhere of Match Values and corresponding Multipliers and use this array formula:
=SUM(IF($C$7:$CO$7=$A$2:$A$5,$B$2:$B$5,0))
Commit the array formula by pressing Ctrl+Shift+Enter.
Note my screen shot truncates the data range. 14 is the correct answer for the data I entered.

Resources