Trying to use indirect to make a formula dynamic - excel

Ok, so I am trying to do something I thought was very simple, but it is turning out to be more complicated.
What I am trying to do:
Take a value through an if statement and return 1 or 0. But I want to be able to change the formula by changing values in cells and not editing the formula itself.
Example:
cell A1 = 41%
cell B1 = >
cell C1 = 40%
cell D1 = Formula with calculation
I want to create a formula that will tell me if that 41% is > than 40%, but if I change that > in B1 for a < (in a separate cell outside the cell with the formula) or I change C1 I want it to recalculate.
I have tried the following:
=IF(A1&B1&C1,1,0)
=IF(A1&INDIRECT(B1)&C1,1,0)
=IF(INDIRECT(A1)&INDIRECT(B1)&INDIRECT(C1),1,0)
all of these result in errors and I cannot figure out how to make it work. I am assuming it is taking the > and making it a string instead of a part of the formula.
Thanks for the help.

=COUNTIF( A1, B1&C1 )
... seems to do the trick, although converting C1 to text may give some rounding errors
An alternative would of course be to enumerate all the operations:
=--IFS( B1=">", A1>C1, B1="<", A1<C1 )
And add other operators as you come across them (NB the -- turns TRUE/FALSE into 1/0)

Related

Excel IF statements, with 3 conditions if a=true and b=true and c=true then d1 = ""

I want to make an excel formula so that, I can test out 3 columns and if they are true then to set a new value to the 4rth column.
I have this formula:
=IF(AND(A1="ALFA ROMEO"; B1="159"; C1="55");D1="2016";D1="")
and I want to check if A1 and B1 and C1 are true then to set D1 equal to a certain value.
*I've tried many complex ways to achieve it but this formula is the only one that doesnt pop up an error, but still gives back the Value FALSE(Not in D1, but in the cell I tried it). I've also tried seperating with commas etc...
Any possible help or way I could achieve the check?
It should come from the quote ("") around the number
I've try this
=SI(ET(A1="ALFA ROMEO";B1=159;C1=55);2016;"")
and it worked for me (sorry it's in french).
Maybe try to change cell format from the column B and C.
And also put the formula in cell D1 or in the cell you want the value.
You're almost there, but you need to put this formula here in cell D1 in order to fill the value of D1:
=IF(AND(A1="ALFA ROMEO", B1=159, C1=55),2016,"")
Keep out: in my locale I'm working with commas, while you might be working with semicolons, so your actual formula might be (in cell D1):
=IF(AND(A1="ALFA ROMEO"; B1=159; C1=55);2016;"")
Also, no need to put numerical values (159, 55) as strings, as you can see.
Edit: about turning B1 into a string:
I've just created this formula:
=IF(TEXT(B1,"0")="159","TRUE","FALSE")
This allows you to convert B1 into text.
So, your formula might turn into something like:
=IF(AND(A1="ALFA ROMEO", TEXT(B1, "0")="159", TEXT(C1,"0")="55"),2016,"")
(Again, mind the locale settings (commas and semicolons))

fix a formula against targets move in MS Excel

I am making a simple Expense report with columns as shown in
The formula # D3 and on is D3 = =D2-B3
the problem comes when, sometimes, i need to feed in a previous dates,
then i am required to move/insert a row in the Range A1:C#!
this result in shifting the values of B# in Column D ... formulas
lookie result:
Even if i manually enter = $D$2 - $B$3 for the entire Column D,
when i move B3 to B4... the D formula gets messed up.
How can i fix the formulas to always be = D[previous row] - B[current row]?
Try this in D3 and fill down.
=INDEX(D:D, ROW()-1)-INDEX(B:B, ROW())
You may try to indirectly reference the cells using INDIRECT function like this:
=INDIRECT("D"&(ROW()-1))-INDIRECT("B"&ROW())
The concatenated text string "D" and the output of ROW function inside the parentheses form a reference-like string (i.e. D3, D4, D5, etc.) that is evaluated by INDIRECT function to display their values. Very useful if you'd like to use it in such a way as you describe it. Use sparingly, though as it is a volatile function and could be slow in large workbooks.
Hope this helps..
References:
INDIRECT function

Explode an Excel formula into a formula that relies only on cells that don't refer to other cells

I'm looking for a way to unpack an excel formula into a formula that depends only cells that don't refer to other cells.
Example: in the spreadsheet below, cell A1 contains the formula "B1 + B2". Meanwhile, cell B1 contains the formula "C1 + D1", while B2 contains the formula "C2 + D2". Cells C1, C2, D1 and D2 are all constants (in this case, the values 1, 2, 3 and 4).
What I want: I'm looking for a way (either already built into excel, or a user-defined function in VBA), that would function like this:
Call: =ExplodeFormula(A1)
Returns: "C1 + D1 + C2 + D2"
Any chance someone can help me out here? Thanks!
(Edit) A few things I think will be needed for this:
Some way to distinguish a cell reference in a formula from the functions used in that formula.
Some way to distinguish a range reference from a single cell reference (if a cell is referring to a range, like it would in the case of a vlookup, I'd be fine stopping at that level.
A way to iterate through the portions of the formula identified in parts 1 and 2 and break them down into simpler chunks that are recursively run through the same process.
You would have to build an Excel formula parser and apply it recursively to the formulas referred to by any references found in the original formula. And watch out for circular and repeated references!
There are a few formula parsers around, see for starters:
http://ewbi.blogs.com/develops/popular/excelformulaparsing.html
and as a matter of curiosity: why would you want to do this?

Subtraction with blank cells - Excel

I created spreadsheet for budgeting purposes and have it set up so that every time I add some data in my income or expenses column, my balance column automatically posts a readjusted value. However, my formula only seems to work for positive values (see conflict on row 4 of example) Here's what I have so far, pasted in as an array formula in B3 and copied down.
=IF((ISNUMBER(C3:D3)),B2+C3-D3,"")
How could improve the "if true" section of my formula?
the problem you're having is your if statement will return false if either C or D is not a number. if(c through d is a number) will mean that it only is true when both are numbers.
If you want to make it so that you only evaluate numbers (and not treat blanks as 0), then you'll probably want to make an OR statement:
=IF(OR(ISNUMBER(C3),ISNUMBER(D3)),B2+C3-D3,"")
Just be aware that if the relative location of B2 is missing data (if you did not have any expense or income the previous day/week/whatever), then the next field will become a value error when you add something. So if B5 is empty because you didn't do any spending or gaining, then when you spend and put value in "expense" on D6, B6 will become #Value.
To fix this, it might be a good idea to finish off not with an empty string, but with the value of the previous date. It's up to you if you want to use it that way.
=IF(OR(ISNUMBER(C3),ISNUMBER(D3)),B2+C3-D3,B2)
You could try the following, applied on B3:
=IF(AND(ISBLANK(C3),ISBLANK(D3)),"",B2+C3-D3)
This way, you don't need an array formula - I'm just checking if C3 AND D3 are blank - if so, the cell will be empty, otherwise will do the math.
You could put an Or statement in so that if either C3 or D3 is a number, then calculate accordingly.
=IF(Or(ISNUMBER(C3),ISNUMBER(D3)),B2+C3-D3,"")

EXCEL How do I ignore a cell if a cell has a value

I have a row that will have weekly values entered. Column B has the initial value, and E has the calculation; as I add values to C, D and so on, I want the calculation to skip the previous columns value when the next column gets a value.
B1-C1=E1 BUT when a value is added to D1, E1 would update to B1-D1=E1
Sorry for the horrible description. This is probably answered somewhere on this site but I am not sure what terms to search.
Many thanks!
you can use an if statement. I am not 100% sure of your problem but something like this might be helpful.
if(A1, A1, 0)
So for your example provided.
=B1-if(D1, D1, C1)
This says if there is a value in D1 use D1 else use C1. This works in this example, because if
D1 is empty or 0 you will use the other cell. This may change for any given problem.
Use this if function in E1:
=IF(D1>0,B1-D1,IF(C1>0,B1-C1,B1))
Then enter a value in B1, then C1 then D1 to see the results.
According to your question, you only have room for two entries after the default B1 value. This statement will handle that.
If you need more fields, nest more if functions. But if's can only be nested 7 deep, so you can only have an initial value in B1 and 7 more cells, C1 to I1 with your formula in J1
If you actual data is as simple as your sample data you could just use:
=IF(LEN(D2)>0, B2-D2,B2-C2)
You could also use:
=IF(ISBLANK(D2), B2-C2, B2-D2)
if you prefer but Len is a little shorter and I believe the ISBLANK() function has flaws, If you have a formula in D2 that has a calculation and you set the result to "" then it will pick up as false. It depends on your needs.
I would do the following.
In E1 paste the following:
=A1-INDEX(B1:D1,1,COUNT(B1:D1))
The count formula will tell how many values are present in the range of B:D column. This will be used to catch the last column with an index formula which will be deducted form A1.
One thing is very important! The values from A to D has to be written in sequence, if one column is missing than the calculation will be false.
Hope I could help!

Resources