Related
I wrote a formula which exceeds 8192 characters and I really need to reach the result of the formula. Actually it is repetetive calculation for different conditions. I'm sure when you see the formula you will get the idea. But there is short explanation below:
There are 10 different sources and regarding choosen source formula should work.
Regarding choosen currency I need to get result of related calculation.
Right now it is 10.290 chars.
Since this is my first question and I'm kinda new on Excel any help would be appreciated.
*Expected result need to be shown on "unit price" column and different for each item.
=IFERROR(IF(core!$D$11=1;IF($F15>0;IF(core!$D$7="TL";IF(core!$H29="TL";core!$I29+core!$I29*core!$F29+core!$I29*core!$g29;IF(core!$H29="USD";core!$I29*core!$N$2+core!$I29*core!$N$2*core!$F29+core!$I29*core!$N$2*core!$g29;IF(core!$H29="EURO";core!$I29*core!$N$3+core!$I29*core!$N$3*core!$F29+core!$I29*core!$N$3*core!$g29;"")));
IF(core!$D$11=1;IF($F15>0;IF(core!$D$7="USD";IF(core!$H29="TL";core!$I29/core!$N$2+core!$I29/core!$N$2*core!$F29+core!$I29/core!$N$2*core!$g29;IF(core!$H29="USD";core!$I29+core!$I29*core!$F29+core!$I29*core!$g29;IF(core!$H29="EURO";core!$I29*core!$N$3/core!$N$2+core!$I29*core!$N$3/core!$N$2*core!$F29+core!$I29*core!$N$3/core!$N$2*core!$g29;"")));
IF(core!$D$11=1;IF($F15>0;IF(core!$D$7="EURO";IF(core!$H29="TL";(core!$I29/core!$N$3+core!$I29/core!$N$3*core!$F29+core!$I29/core!$N$3*core!$g29);IF(core!$H29="USD";(core!$I29*core!$N$2/core!$N$3+core!$I29*core!$N$2/core!$N$3*core!$F29+core!$I29*core!$N$2/core!$N$3*core!$g29);IF(core!$H29="EURO";core!$I29+core!$I29*core!$F29+core!$I29*core!$g29;""))))))))))));
IF(core!$D$11=2;IF($F15>0;IF(core!$D$7="TL";IF(core!$H29="TL";core!$K29+core!$K29*core!$F29+core!$K29*core!$g29;IF(core!$H29="USD";core!$K29*core!$N$2+core!$K29*core!$N$2*core!$F29+core!$K29*core!$N$2*core!$g29;IF(core!$H29="EURO";core!$K29*core!$N$3+core!$K29*core!$N$3*core!$F29+core!$K29*core!$N$3*core!$g29;"")));
IF(core!$D$11=2;IF($F15>0;IF(core!$D$7="USD";IF(core!$H29="TL";core!$K29/core!$N$2+core!$K29/core!$N$2*core!$F29+core!$K29/core!$N$2*core!$g29;IF(core!$H29="USD";core!$K29+core!$K29*core!$F29+core!$K29*core!$g29;IF(core!$H29="EURO";core!$K29*core!$N$3/core!$N$2+core!$K29*core!$N$3/core!$N$2*core!$F29+core!$K29*core!$N$3/core!$N$2*core!$g29;"")));
IF(core!$D$11=2;IF($F15>0;IF(core!$D$7="EURO";IF(core!$H29="TL";core!$K29/core!$N$3+core!$K29/core!$N$3*core!$F29+core!$K29/core!$N$3*core!$g29;IF(core!$H29="USD";core!$K29*core!$N$2/core!$N$3+core!$K29*core!$N$2/core!$N$3*core!$F$29+core!$K29*core!$N$2/core!$N$3*core!$g$29;IF(core!$H29="EURO";core!$K29+core!$K29*core!$F29+core!$K29*core!$g29;"")))))))))));
IF(core!$D$11=3;IF($F15>0;
IF(core!$D$7="TL";IF(core!$H29="TL";core!$M29+core!$M29*core!$F29+core!$M29*core!$g29;IF(core!$H29="USD";core!$M29*core!$N$2+core!$M29*core!$N$2*core!$F29+core!$M29*core!$N$2*core!$g29;IF(core!$H29="EURO";core!$M29*core!$N$3+core!$M29*core!$N$3*core!$F29+core!$M29*core!$N$3*core!$g29;"")));
IF(core!$D$11=3;IF($F15>0;IF(core!$D$7="USD";IF(core!$H29="TL";core!$M29/core!$N$2+core!$M29/core!$N$2*core!$F29+core!$M29/core!$N$2*core!$g29;IF(core!$H29="USD";core!$M29+core!$M29*core!$F29+core!$M29*core!$g29;IF(core!$H29="EURO";core!$M29*core!$N$3/core!$N$2+core!$M29*core!$N$3/core!$N$2*core!$F29+core!$M29*core!$N$3/core!$N$2*core!$g29;"")));
IF(core!$D$11=3;IF($F15>0;IF(core!$D$7="EURO";IF(core!$H29="TL";core!$M29/core!$N$3+core!$M29/core!$N$3*core!$F29+core!$M29/core!$N$3*core!$g29;IF(core!$H29="USD";core!$M29*core!$N$2/core!$N$3+core!$M29*core!$N$2/core!$N$3*core!$F29+core!$M29*core!$N$2/core!$N$3*core!$g29;IF(core!$H29="EURO";core!$M29+core!$M29*core!$F29+core!$M29*core!$g29;"")))))))))));
IF(core!$D$11=4;IF($F15>0;
IF(core!$D$7="TL";IF(core!$H29="TL";core!$O29+core!$O29*core!$F29+core!$O29*core!$g29;IF(core!$H29="USD";core!$O29*core!$N$2+core!$O29*core!$N$2*core!$F29+core!$O29*core!$N$2*core!$g29;IF(core!$H29="EURO";core!$O29*core!$N$3+core!$O29*core!$N$3*core!$F29+core!$O29*core!$N$3*core!$g29;"")));
IF(core!$D$11=4;IF($F15>0;IF(core!$D$7="USD";IF(core!$H29="TL";core!$O29/core!$N$2+core!$O29/core!$N$2*core!$F29+core!$O29/core!$N$2*core!$g29;IF(core!$H29="USD";core!$O29+core!$O29*core!$F29+core!$O29*core!$g29;IF(core!$H29="EURO";core!$O29*core!$N$3/core!$N$2+core!$O29*core!$N$3/core!$N$2*core!$F29+core!$O29*core!$N$3/core!$N$2*core!$g29;"")));
IF(core!$D$11=4;IF($F15>0;IF(core!$D$7="EURO";IF(core!$H29="TL";core!$O29/core!$N$3+core!$O29/core!$N$3*core!$F29+core!$O29/core!$N$3*core!$g29;IF(core!$H29="USD";core!$O29*core!$N$2/core!$N$3+core!$O29*core!$N$2/core!$N$3*core!$F29+core!$O29*core!$N$2/core!$N$3*core!$g29;IF(core!$H29="EURO";core!$O29+core!$O29*core!$F29+core!$O29*core!$g29;"")))))))))));
IF(core!$D$11=5;IF($F15>0;
IF(core!$D$7="TL";IF(core!$H29="TL";core!$Q29+core!$Q29*core!$F29+core!$Q29*core!$g29;IF(core!$H29="USD";core!$Q29*core!$N$2+core!$Q29*core!$N$2*core!$F29+core!$Q29*core!$N$2*core!$g29;IF(core!$H29="EURO";core!$Q29*core!$N$3+core!$Q29*core!$N$3*core!$F29+core!$Q29*core!$N$3*core!$g29;"")));
IF(core!$D$11=5;IF($F15>0;IF(core!$D$7="USD";IF(core!$H29="TL";core!$Q29/core!$N$2+core!$Q29/core!$N$2*core!$F29+core!$Q29/core!$N$2*core!$g29;IF(core!$H29="USD";core!$Q29+core!$Q29*core!$F29+core!$Q29*core!$g29;IF(core!$H29="EURO";core!$Q29*core!$N$3/core!$N$2+core!$Q29*core!$N$3/core!$N$2*core!$F29+core!$Q29*core!$N$3/core!$N$2*core!$g29;"")));
IF(core!$D$11=5;IF($F15>0;IF(core!$D$7="EURO";IF(core!$H29="TL";core!$Q29/core!$N$3+core!$Q29/core!$N$3*core!$F29+core!$Q29/core!$N$3*core!$g29;IF(core!$H29="USD";core!$Q29*core!$N$2/core!$N$3+core!$Q29*core!$N$2/core!$N$3*core!$F29+core!$Q29*core!$N$2/core!$N$3*core!$g29;IF(core!$H29="EURO";core!$Q29+core!$Q29*core!$F29+core!$Q29*core!$g29;"")))))))))));
IF(core!$D$11=6;IF($F15>0;
IF(core!$D$7="TL";IF(core!$H29="TL";core!$S29+core!$S29*core!$F29+core!$S29*core!$g29;IF(core!$H29="USD";core!$S29*core!$N$2+core!$S29*core!$N$2*core!$F29+core!$S29*core!$N$2*core!$g29;IF(core!$H29="EURO";core!$S29*core!$N$3+core!$S29*core!$N$3*core!$F29+core!$S29*core!$N$3*core!$g29;"")));
IF(core!$D$11=6;IF($F15>0;IF(core!$D$7="USD";IF(core!$H29="TL";core!$S29/core!$N$2+core!$S29/core!$N$2*core!$F29+core!$S29/core!$N$2*core!$g29;IF(core!$H29="USD";core!$S29+core!$S29*core!$F29+core!$S29*core!$g29;IF(core!$H29="EURO";core!$S29*core!$N$3/core!$N$2+core!$S29*core!$N$3/core!$N$2*core!$F29+core!$S29*core!$N$3/core!$N$2*core!$g29;"")));
IF(core!$D$11=6;IF($F15>0;IF(core!$D$7="EURO";IF(core!$H29="TL";core!$S29/core!$N$3+core!$S29/core!$N$3*core!$F29+core!$S29/core!$N$3*core!$g29;IF(core!$H29="USD";core!$S29*core!$N$2/core!$N$3+core!$S29*core!$N$2/core!$N$3*core!$F29+core!$S29*core!$N$2/core!$N$3*core!$g29;IF(core!$H29="EURO";core!$S29+core!$S29*core!$F29+core!$S29*core!$g29;"")))))))))));
IF(core!$D$11=7;IF($F15>0;
IF(core!$D$7="TL";IF(core!$H29="TL";core!$U29+core!$U29*core!$F29+core!$U29*core!$g29;IF(core!$H29="USD";core!$U29*core!$N$2+core!$U29*core!$N$2*core!$F29+core!$U29*core!$N$2*core!$g29;IF(core!$H29="EURO";core!$U29*core!$N$3+core!$U29*core!$N$3*core!$F29+core!$U29*core!$N$3*core!$g29;"")));
IF(core!$D$11=7;IF($F15>0;IF(core!$D$7="USD";IF(core!$H29="TL";core!$U29/core!$N$2+core!$U29/core!$N$2*core!$F29+core!$U29/core!$N$2*core!$g29;IF(core!$H29="USD";core!$U29+core!$U29*core!$F29+core!$U29*core!$g29;IF(core!$H29="EURO";core!$U29*core!$N$3/core!$N$2+core!$U29*core!$N$3/core!$N$2*core!$F29+core!$U29*core!$N$3/core!$N$2*core!$g29;"")));
IF(core!$D$11=7;IF($F15>0;IF(core!$D$7="EURO";IF(core!$H29="TL";core!$U29/core!$N$3+core!$U29/core!$N$3*core!$F29+core!$U29/core!$N$3*core!$g29;IF(core!$H29="USD";core!$U29*core!$N$2/core!$N$3+core!$U29*core!$N$2/core!$N$3*core!$F29+core!$U29*core!$N$2/core!$N$3*core!$g29;IF(core!$H29="EURO";core!$U29+core!$U29*core!$F29+core!$U29*core!$g29;"")))))))))));
IF(core!$D$11=8;IF($F15>0;
IF(core!$D$7="TL";IF(core!$H29="TL";core!$W29+core!$W29*core!$F29++core!$W29*core!$g29;IF(core!$H29="USD";core!$W29*core!$N$2+core!$W29*core!$N$2*core!$F29+core!$W29*core!$N$2*core!$g29;IF(core!$H29="EURO";core!$W29*core!$N$3+core!$W29*core!$N$3*core!$F29+core!$W29*core!$N$3*core!$g29;"")));
IF(core!$D$11=8;IF($F15>0;IF(core!$D$7="USD";IF(core!$H29="TL";core!$W29/core!$N$2+core!$W29/core!$N$2*core!$F29+core!$W29/core!$N$2*core!$g29;IF(core!$H29="USD";core!$W29+core!$W29*core!$F29+core!$W29*core!$g29;IF(core!$H29="EURO";core!$W29*core!$N$3/core!$N$2+core!$W29*core!$N$3/core!$N$2*core!$F29+core!$W29*core!$N$3/core!$N$2*core!$g29;"")));
IF(core!$D$11=8;IF($F15>0;IF(core!$D$7="EURO";IF(core!$H29="TL";core!$W29/core!$N$3+core!$W29/core!$N$3*core!$F29+core!$W29/core!$N$3*core!$g29;IF(core!$H29="USD";core!$W29*core!$N$2/core!$N$3+core!$W29*core!$N$2/core!$N$3*core!$F29+core!$W29*core!$N$2/core!$N$3*core!$g29;IF(core!$H29="EURO";core!$W29+core!$W29*core!$F29+core!$W29*core!$g29;"")))))))))));
IF(core!$D$11=9;IF($F15>0;
IF(core!$D$7="TL";IF(core!$H29="TL";core!$Y29+core!$Y29*core!$F29+core!$Y29*core!$g29;IF(core!$H29="USD";core!$Y29*core!$N$2+core!$Y29*core!$N$2*core!$F29+core!$Y29*core!$N$2*core!$g29;IF(core!$H29="EURO";core!$Y29*core!$N$3+core!$Y29*core!$N$3*core!$F29+core!$Y29*core!$N$3*core!$g29;"")));
IF(core!$D$11=9;IF($F15>0;IF(core!$D$7="USD";IF(core!$H29="TL";core!$Y29/core!$N$2+core!$Y29/core!$N$2*core!$F29+core!$Y29/core!$N$2*core!$g29;IF(core!$H29="USD";core!$Y29+core!$Y29*core!$F29+core!$Y29*core!$g29;IF(core!$H29="EURO";core!$Y29*core!$N$3/core!$N$2+core!$Y29*core!$N$3/core!$N$2*core!$F29+core!$Y29*core!$N$3/core!$N$2*core!$g29;"")));
IF(core!$D$11=9;IF($F15>0;IF(core!$D$7="EURO";IF(core!$H29="TL";core!$Y29/core!$N$3+core!$Y29/core!$N$3*core!$F29+core!$Y29/core!$N$3*core!$g29;IF(core!$H29="USD";core!$Y29*core!$N$2/core!$N$3+core!$Y29*core!$N$2/core!$N$3*core!$F29+core!$Y29*core!$N$2/core!$N$3*core!$g29;IF(core!$H29="EURO";core!$Y29+core!$Y29*core!$F29+core!$Y29*core!$g29;"")))))))))));
IF(core!$D$11=10;IF($F15>0;
IF(core!$D$7="TL";IF(core!$H29="TL";core!$AA29+core!$AA29*core!$F29+core!$AA29*core!$g29;IF(core!$H29="USD";core!$AA29*core!$N$2+core!$AA29*core!$N$2*core!$F29+core!$AA29*core!$N$2*core!$g29;IF(core!$H29="EURO";core!$AA29*core!$N$3+core!$AA29*core!$N$3*core!$F29+core!$AA29*core!$N$3*core!$g29;"")));
IF(core!$D$11=10;IF($F15>0;IF(core!$D$7="USD";IF(core!$H29="TL";core!$AA29/core!$N$2+core!$AA29/core!$N$2*core!$F29+core!$AA29/core!$N$2*core!$g29;IF(core!$H29="USD";core!$AA29+core!$AA29*core!$F29+core!$AA29*core!$g29;IF(core!$H29="EURO";core!$AA29*core!$N$3/core!$N$2+core!$AA29*core!$N$3/core!$N$2*core!$F29+core!$AA29*core!$N$3/core!$N$2*core!$g29;"")));
IF(core!$D$11=10;IF($F15>0;IF(core!$D$7="EURO";IF(core!$H29="TL";core!$AA29/core!$N$3+core!$AA29/core!$N$3*core!$F29+core!$AA29/core!$N$3*core!$g29;IF(core!$H29="USD";core!$AA29*core!$N$2/core!$N$3+core!$AA29*core!$N$2/core!$N$3*core!$F29+core!$AA29*core!$N$2/core!$N$3*core!$g29;IF(core!$H29="EURO";core!$AA29+core!$AA29*core!$F29+core!$AA29*core!$g29;""))))))))))))))))))))
*(core!$G29+1))
enter image description here
The IFERROR has the format IFERROR(Value, Value_if_error). Your Value is this:
IF(core!$D$11=1;IF($F15>0;IF(core!$D$7="TL";IF(core!$H29="TL";core!$I29+core!$I29*core!$F29+core!$I29*core!$g29;IF(core!$H29="USD";core!$I29*core!$N$2+core!$I29*core!$N$2*core!$F29+core!$I29*core!$N$2*core!$g29;IF(core!$H29="EURO";core!$I29*core!$N$3+core!$I29*core!$N$3*core!$F29+core!$I29*core!$N$3*core!$g29;"")));IF(core!$D$11=1;IF($F15>0;IF(core!$D$7="USD";IF(core!$H29="TL";core!$I29/core!$N$2+core!$I29/core!$N$2*core!$F29+core!$I29/core!$N$2*core!$g29;IF(core!$H29="USD";core!$I29+core!$I29*core!$F29+core!$I29*core!$g29;IF(core!$H29="EURO";core!$I29*core!$N$3/core!$N$2+core!$I29*core!$N$3/core!$N$2*core!$F29+core!$I29*core!$N$3/core!$N$2*core!$g29;"")));IF(core!$D$11=1;IF($F15>0;IF(core!$D$7="EURO";IF(core!$H29="TL";(core!$I29/core!$N$3+core!$I29/core!$N$3*core!$F29+core!$I29/core!$N$3*core!$g29);IF(core!$H29="USD";(core!$I29*core!$N$2/core!$N$3+core!$I29*core!$N$2/core!$N$3*core!$F29+core!$I29*core!$N$2/core!$N$3*core!$g29);IF(core!$H29="EURO";core!$I29+core!$I29*core!$F29+core!$I29*core!$g29;""))))))))))));
Taking your formula, splitting out the first part of the IFERROR, and eliminating the spurious code (i.e. IF(A=1, IF(B=2, IF(A=1, ALWAYS_TRUE, ALWAYS_FALSE), C), D) is functionally identical to IF(A=1, IF(B=2, ALWAYS_TRUE, C), D)), I then built the following table:
The Red, Blue and Green text are Common Terms, present in every formula.
Examining this, and rearranging it slightly, I spot the following patterns:
When D7 is "USD", Divide by $N$2
When D7 is "EURO", Divide by $N$3
When H29 is "USD", Multiply by $N$2
When H29 is "EURO", Multiply by $N$3
Implicitly, the following rules also exist:
When D7 is "TL", Divide by 1
When H29 is "TL", Multiply by 1
I can use a VLOOKUP to pick which cells to use, resulting in the form VLOOKUP(H29,..) * (Common_Terms) / VLOOKUP(D7,..)
This allows me to rewrite your Value as follows:
IF(AND(core!$D$11=1,$F15>0), IF(AND(MATCH(core!$D$11,{"TL","USD","EURO","*"},0)<4, MATCH(core!$H$29,{"TL","USD","EURO","*"},0)<4), VLOOKUP(core!H$29,{"USD",core!$N$2;"Euro",core!$N$3;"TL",1},2,FALSE)*(core!$I29 + core!$I29*core!$F29 + core!$I29*core!$g29)/VLOOKUP(core!H$29,{"USD",core!$N$2;"Euro",core!$N$3;"TL",1},2,FALSE), ""), FALSE)
Which is a third of the length. You should be able to manage similar optimisation of almost every IF condition you have.
More importantly, a lot of your repeated (and unnecessary) IF conditions are checking if H29 and D7 are "TL"/"USD"/"EUR", or checking that F15>0. You can eliminate these by making your outermost IF statement look like this:
=IF(AND($F15>0, MATCH(core!$D$7, core!$D$11, {"TL","USD","EURO","*"},0)<4, MATCH(core!$H$29, {"TL","USD","EURO","*"},0)<4), ALL_THREE_CONTITIONS_ARE_TRUE, "")
I have an issue at the moment which I'm not able to resolve even with multiple combinations of If and Vlookups. I'm not doing this right.
I have a sheet which has the names of the products and an empty column for the Sl Number. The Sl number needs to be retrieved from Sheet 2 if it matches the value in the adjacent cell of the formula (This I know can be possible with Vlookup). However, I am trying to display the value even if the match is not exact. By that I mean if the product name has all the values as on the sheet 1 but also has additional information in brackets, then the value should still be displayed.
Sheet 1
Formula in A2 - A7 = "=VLOOKUP(B2, Sheet2!B:E, 2, 0)"
Sheet 2
The complete data
Is this possible?
Thanks in advance.
Apologies, I'm new here and not sure how this works. So trying to do the right thing but may take some time.
Thanks Frank and Tim. I have another extended question to this.
Is there a way to retrieve the value by ignoring text in brackets on the lookup cell itself?
For example:
Sheet 1
Sl Number Name
123454 Cream SPF 30+ 50g
**NA** Bar Chocolate 70g X 6 (Sample)
234256 Hand Wash 150ml
26786 Toothpaste - Whitening 110g
Sheet 2
ID Name Sl number Manufacturer Quantity
8 Collagen Essence 10ml 456788 AL 87
9 Hand Wash 150ml 234256 AD 23
10 Bar Chocolate 70g X 6 835424 AU 234
Row 2 on Sheet 1 has the name that includes (Sample) and the same product on sheet 2 does not contain the (Sample) for that product. Is there a way I can use lookup in the above scenario?
Thank you
Tim's comment
=VLOOKUP(B2 & "*", Sheet2!B:E, 2, 0) as long as the "Extra" info is tagged onto the end of the name, and none of your product names is a
substring of another product name. – Tim Williams 53 mins ago
Will get what you are looking for, as for getting rid of text between "(...)" use
=IFERROR(IF(FIND("(",A2),LEFT(A2,FIND("(",A2)-1),A2),A2)
To create a new column that will cut out anything that has parentheses "(...)" this presumes that all of your entries has the "(...)" at the end, i.e. far right side.
As you are new, I presume you might be interested in an explanation. I'll explain what Tim and I did. If I am incorrect, anyone is free to edit.
Based on your question, it would appear that you are familiar with Excel but not the site. This said, my understanding of the key difference between your attempt and Tim's was =VLOOKUP(B2 & "*", Sheet2!B:E, 2, 0) or specifically & "*". This introduces a Wildcard to the search parameter. So if you typed "Bob" but the actual reference was "Bob's Burger" That "*" would allow ['s Burger] to be included as part of the possible search given that you set vLookup to search for Approximate rather than exact matches. =VLOOKUP(B2 & "*", Sheet2!B:E, 2, 0) specifically , 0).
As for my part, IFERROR is effectively an catch-all for errors in IF functions. If there is a error, then X. In this case, if it does not find "(" in the cell, then it will throw an error. Since it is an error, display the original cell.
As for IF(FIND("(",A2),LEFT(A2,FIND("(",A2)-1),A2) It asks Excel to look for "(" in the cell A2, if it finds it, then it it counts from the LEFT until it finds the "(" and deletes the text one space to the left of the first "(". Thus removing the "(...)".
Say I have columns
/670 - White | /650 - black | /680 - Red | /800 - Whitest
These have data in their rows. Basically, I want to SUM their values together if their headers contain my desired string.
For modularity's sake, I wanted to merely specify to sum /670, /650, and /680 without having to mention the rest of the header text.
So, something like =SUMIF(a1:c1; "/NUM & /NUM & /NUM"; a2:c2)
That doesn't work, and honestly I don't know what i should be looking for.
Additional stuff:
I'm trying to think of the answer myself, is it possible to mention the header text as condition for ifs? Like: if A2="/650 - Black" then proceed to sum the next header. Is this possible?
Possibility it would not involve VBA, a draggable formula would be preferable!
At this point, I may as well request a version which handles the complete header name rather than just a part of it as I believe it to be difficult for formula code alone.
Thanks for having a look!
Let me know if I need to elaborate.
EDIT: In regards to data samples, any positive number will do actually, damn shame stack overflow doesn't support table markdown. Anyway, for example then..:
+-------------+-------------+-------------+-------------+-------------+
| A | B | C | D | E |
+---+-------------+-------------+-------------+-------------+-------------+
| 1 |/650 - Black |/670 - White |/800 - White |/680 - Red |/650 - Black |
+---+-------------+-------------+-------------+-------------+-------------+
| 2 | 250 | 400 | 100 | 300 | 125 |
+---+-------------+-------------+-------------+-------------+-------------+
I should have clarified:
The number range for these headers would go from /100 - /9999 and no more than that.
EDIT:
Progress so far:
https://docs.google.com/spreadsheets/d/1GiJKFcPWzG5bDsNt93eG7WS_M5uuVk9cvkt2VGSbpxY/edit?usp=sharing
Formula:
=SUMPRODUCT((A2:D2*
(MID($A$1:$D$1,2,4)=IF(LEN($H$1)=4,$H$1&"",$H$1&" ")))+(A2:D2*
(MID($A$1:$D$1,2,4)=IF(LEN($I$1)=4,$I$1&"",$I$1&" ")))+(A2:D2*
(MID($A$1:$D$1,2,4)=IF(LEN($J$1)=4,$J$1&"",$J$1&" "))))
Apparently, each MID function is returning false with each F9 calculation.
EDIT EDIT:
Okay! I found my issue, it's the /being read when you ALSO mentioned that it wasn't required. Man, I should stop skimming!
Final Edit:
=SUMPRODUCT((RETURNSUM*
(MID(HEADER,2,4)=IF(LEN(Match5)=4,Match5&"",Match5&" ")))+(RETURNSUM*
(MID(HEADER,2,4)=IF(LEN(Match6)=4,Match6&"",Match6&" ")))+(RETURNSUM*
(MID(HEADER,2,4)=IF(LEN(Match7)=4,Match7&"",Match7&" ")))
The idea is that Header and RETURNSUM will become match criteria like the matches written above, that way it would be easier to punch new criterion into the search table. As of the moment, it doesn't support multiple rows/dragging.
I have knocked up a couple of formulas that will achieve what you are looking for. For ease I have made the search input require the number only as pressing / does not automatically type into the formula bar. I apologise for the length of the answer, I got a little carried away with the explanation.
I have set this up for 3 criteria located in J1, K1 and L1.
Here is the output I achieved:
Formula 1 - SUMPRODUCT():
=SUMPRODUCT((A4:G4*(MID($A$1:$G$1,2,4)=IF(LEN($J$1)=4,$J$1&"",$J$1&" ")))+(A4:G4*(MID($A$1:$G$1,2,4)=IF(LEN($K$1)=4,$K$1&"",$K$1&" ")))+(A4:G4*(MID($A$1:$G$1,2,4)=IF(LEN($L$1)=4,$L$1&"",$L$1&" "))))
Sumproduct(array1,[array2]) behaves as an array formula without needed to be entered as one. Array formulas break down ranges and calculate them cell by cell (in this example we are using single rows so the formula will assess columns seperately).
(A4:G4*(MID($A$1:$G$1,2,4)=IF(LEN($J$1)=4,$J$1&"",$J$1&" ")))
Essentially I have broken the Sumproduct() formula into 3 identical parts - 1 for each search condition. (A4:G4*: Now, as the formula behaves like an array, we will multiply each individual cell by either 1 or 0 and add the results together.
1 is produced when the next part of the formula is true and 0 for when it is false (default numeric values for TRUE/FALSE).
(MID($A$1:$G$1,2,4)=IF(LEN($J$1)=4,$J$1&"",$J$1&" "))
MID(text,start_num,num_chars) is being used here to assess the 4 digits after the "/" and see whether they match with the number in the 3 cells that we are searching from (in this case the first one: J1). Again, as SUMPRODUCT() works very much like an array formula, each cell in the range will be assessed individually.
I have then used the IF(logical_test,[value_if_true],[value_if_false]) to check the length of the number that I am searching. As we are searching for a 4 digit text string, if the number is 4 digits then add nothing ("") to force it to a text string and if it is not (as it will have to be 3 digits) add 1 space to the end (" ") again forcing it to become a text string.
The formula will then perform the calculation like so:
The MID() formula produces the array: {"650 ","670 ","800 ","680 ","977 ","9999","143 "}. This combined with the first search produces {TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE} which when multiplied by A4:G4
(remember 0 for false and 1 for true) produces this array: {250,0,0,0,0,0,0} essentially pulling the desired result ready to be summed together.
Formula 2: =SUM(IF(Array)): [This formula does not work for 3 digit numbers as they will exist within the 4 digit numbers! I have included it for educational purposes only]
=SUM(IF(ISNUMBER(SEARCH($J$1,$A$1:$G$1)),A8:G8),IF(ISNUMBER(SEARCH($K$1,$A$1:$G$1)),A8:G8),IF(ISNUMBER(SEARCH($L$1,$A$1:$G$1)),A8:G8))
The formula will need to be entered as an array (once copy and pasted while still in the formula bar hit CTRL+SHIFT+ENTER)
This formula works in a similar way, SUM() will add together the array values produced where IF(ISNUMBER(SEARCH() columns match the result column.
SEARCH() will return a number when it finds the exact characters in a cell which represents it's position in number of characters. By using ISNUMBER() I am avoiding having to do the whole MID() and IF(LEN()=4,""," ") I used in the previous formula as TRUE/FALSE will be produced when a match is found regardless of it's position or cell formatting.
As previously mentioned, this poses a problem as 999 can be found within 9999 etc.
The resulting array for the first part is: {250,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE} (if you would like to see the array you can highlight that part of the formula and calculate with F9 but be sure to highlight the exact brackets for that part of the formula).
I hope I have explained this well, feel free to ask any questions about stuff that you don't understand. It is good to see people keen to learn and not just fishing for a fast answer. I would be more than happy to help and explain in more depth.
I start this solution with the names in an array, you can read the header names into an array with not too much difficulty.
Sub test()
Dim myArray(1 To 4) As String
myArray(1) = "/670 - White"
myArray(2) = "/650 - black"
myArray(3) = "/680 - Red"
myArray(4) = "/800 - Whitest"
For Each ArrayValue In myArray
'Find position of last character
endposition = InStr(1, ArrayValue, " - ", vbTextCompare)
'Grab the number section from the string, based on starting and ending positions
stringvalue = Mid(ArrayValue, 2, endposition - 2)
'Convert to number
NumberValue = CLng(stringvalue)
'Add to total
Total = Total + NumberValue
Next ArrayValue
'Print total
Debug.Print Total
End Sub
This will print the answer to the debug window.
First I'm no Excel formula guru..
I want to write a formula that is comparing 4 possible string values
such as: Up, Down, Left, Right
pseudocode would be say:
if a1="Up" and a2="Down" then 1.1
else if a1="Left" and a2="Right" then 1.1
else if a1="Left" and a2="Down" then .95
else if a1 = a2 then 1
I'd cover all the permutations..
I view it as 6 nested if tests
4 items to test/compare
6 tests emerge
1x2,1x3,1x4,2x3,2x4,3x4
=IF(1=2,do this,if(1=3,do this,if(1=4,do this,if(2=3,do this,if(2=4,do this,if(3=4,do this,value if every test fails))))))
I THINK Excel has a limit of 7 nested if formulas or perhaps even formulas in general.
Perhaps you're looking for something like this?
=IF("Test1"="","Equal1
","")&IF("Test2"="","Equal2
","")&IF("Test3"="","Equal3
","")&IF("Test4"="","Equal4
","")
Borrowed from basically the same question on SuperUser.
I am having some trouble using the custom number format feature in Excel to display US Treasury futures quotes.
The format by which they are displayed in is:
121'167
Which is equivalent to 121 + 16.75/32
If the last digit is a 5, as in 121'165, then it is equivalent to
121 + 16.5/32
If the last digit is a 2, as in 121'162, then it is equivalent to
121 + 16.25/32
and finally if the last digit is a 0, as in 121'160, then it is equivalent to
121 + 16/32
Is there a way to implement this definition using the custom number formatting feature or is it beyond it's capability?
This is one insane format: add fractions, then use decimals in the dividend, and then truncate those decimals...
But enough of the ranting. This should do the job, if I understood your specification correctly:
=TRUNC(A1)&"'"&INT(MOD(A1,1)*320)
Number formats alone cannot do this, because they cannot do actual conversions of the numbers (apart from the built-ins like date/time).
you can apply the TEXT() function to both of your values and concatenate them into a single string.
example (A1 = 121, B1 = 16.75)
C1: =TEXT(A1,"###") & "'" & TEXT(B1*10-1,"###") & "/32"
You need to work out rounding (I put a constant *10-1 into the 2nd term) and how to obtain the "/32" ... I couldn't spot that from your question
Hope that helps
good luck
=TRUNC(A1)&"'"&ROUND((MOD(A1,1)*32),1)
Where A1 = 109.6406
This is what worked best for me. I simply had to take a 2-year note quote in the form of, as an example, 109'20.5 and replicate in excel. I converted the quote into 109.6406 (109 + 20.5/32) and applied the above formula.
I know this is a bit dated, but stumbled upon this today and needed the same information. Here is what I use, replace the cell across the formula to pull the quote.
5 yr:
=LEFT(J22,3)+(RIGHT(J22,3)/320)+IF(INT(RIGHT(J22,1))=2,0.0015625,IF(INT(RIGHT(J22,1))=7,0.0015625,0))
10 yr: =LEFT(B28,3)+(RIGHT(B28,3)/320)