"Concatenate" math operation to cell value - google-sheets

Given data:
A1 = some value
A2 = operations needed like "*(-1) + today()"
Wanted result in A3 is formula which can take A1 and apply operations from A2.
Following my data sample if today is 10/25/2016 and A1 is 10/22/2016 I want to see "3" in A3.
Is this possible?

Yes this is possible by using Google Apps Script, getFormula or getFormulas methods.
Related question:
Is there a way to evaluate a formula that is stored in a cell?

Related

GSHEET How do I Extract Text from formula for creating automatic cell reference

The context :
Each time i need a cell reference from my other sheet, I need others cell reference from the same line but from different column.
I would like to automate those adding reference values depending on the first reference i add manually.
I have a sheet named alpha and a sheet named beta
I have a cell A1 in alpha that refers to beta A1
I have this referred cell formula in alpha A1 to have the value from beta A1
=beta!A1
Objectif :
I would like to have in alpha B2 the cell automatically filled-in by the value from beta A7
the equivalence of this refered cell formula
=beta!A7
Because the number seven will never change, only the column can change it could be:
=beta!AC1
so I will need =beta!AC7 automatically populated.
The Goal :
The goal is to extract from the formula in alpha A1 all characters except number(s) by a formula (like SEARCH, LEN, from FORMULATEXT) to obtain
=beta!A
with this result, I will concatenate with a cell that has the value "7". to obtain the formula for the cell reference.
A
B
C
1
=beta!A1
=beta!A7
7
2
=beta!AC1
=beta!AC7
If anyone can give me this formula clue or a better way to reach my goal would be good
I tried the regex below but it removed the punctuation
=REGEXREPLACE(FORMULATEXT(A1),"[^[:alpha:]]", "")&C1 where C1 is the value "7"
But i have all the need without the exclamation mark "!"
=betaA7
instead of
=beta!A7
Thank you
this is what you want
Use this to REGEXEXTRACT all the numbers and REGEXREPLACE then with "" nothing. and add &$C1 the value in C1.
=REGEXREPLACE(A1, REGEXEXTRACT(A1, "[0-9]+"), "")&$C1
A better way
See in Beta!A1 we have a value of Im beta A1
And in Beta!A7 we have a value of Im beta A7
And in alpha!A1 we hane the formula =beta!A1
To get the value of beta!A7 using the formula in alpha!A1 as an input we use this formula in beta!B1
=INDIRECT(REGEXREPLACE(SUBSTITUTE(FORMULATEXT(A1),"=",""), REGEXEXTRACT(SUBSTITUTE(FORMULATEXT(A1),"=",""), "[0-9]+"), "")&$C1)
Explanation
INDIRECT(=beta!A1)
Even more simpler approach
Use this formula directly
=OFFSET(beta!A1,C1-1,0)

Google Sheets: Print output in another cell

If I use the formula: =UNIQUE(A1:A9) on the B1 cell, the column B will be filled with the unique appearances from A1 to A9. In other words: it will remove duplicates.
The problem is that if I want to order from A to Z of the column C, the formula will be moved to some other place, so it will stop working.
My workaround so far has been this:
However, you will be agree that it's not the most elegant solution.
I'd like to know if it's possible to use a formula in Z1 to print the output starting from Z3.
Is that possible?
I'd like to know if it's possible to use a formula in Z1 to print the output starting from Z3.
use in Z1:
={""; ""; UNIQUE(I3:I313)}

Let user input a value in a cell containing a formula

I have a table that looks like this:
I'm not very familiar with google sheets yet, and I am looking for a way to allow users to input a value in one of the 4 cells containing a formula. Then the other cells would update according to the value the user entered in the cell he chose.
So if a user enters a value in B2 : B3 B4 and B5 would run the formula according to B2's value. And if then if he chooses to enter another value for B4 : B2 B3 and B5 would update accordingly.
I am not sure if what I have in mind is the correct way to do this, or if it is even possible at all. Any ideas on how to proceed?
I just answer according to my understanding, maybe I'm wrong to understand. I think you just paste your formula's in column c and allow your users to put values in B column, this is the way formula do automatic it for you. Sorry for bad English
I mean to put this in column c =B4/4 like bellow
and you get result like bellow
if you want to have custom inputs for values B2, B3, B4, B5 populate these cells with numbers and put your formulas in C column:
if you want to have custom inputs for values 4, 60, 30 then do it like this:

Google Sheets - tricks with Ranges in ArrayFormula

For example you have A1 = {1;2;3}
So, if you want to make cumulative sum in B1 you make this:
B1 = ARRAYFORMULA(SUMIF(ROW(A1:A3);"<="&row(A1:A3);A1:A3))
Or more flexible variant:
B1 =ARRAYFORMULA(SUMIF(INDIRECT("A1:A"&COUNTA(A:A));"<="&INDIRECT("A1:A"&COUNTA(A:A);INDIRECT("A1:A"&COUNTA(R:R)))))
This variant expands according to length of Array in A1 and does not grow to the end of the sheet.
I want to use value of A1 directly in formula like:
=ARRAYFORMULA(sumif(row({1;2;3});"<="&row({1;2;3}));{1;2;3})
But it will not accept {}, because it requires range, but not array.
Does anyone have a trick to override this behavior?
Short answer
=ArrayFormula(sumif({1;2;3},"<="&{1;2;3}))
Explanation
The sintax of SUMIF is SUMIF(range, criterion, [sum_range])
sum_range is an optional parameter to be used when it's different from range. As sum_range and range are the same then the trick is not to use sum_range.
Reference
SUMIF - Docs editors Help

Google spreadsheet formula to resolve string as a cell

Using google spreadsheets is there a way to evaluate a cell value as the row in a lookup operation? For example rather than =D2 to grab the value of D2, I want to evaluate the value of a cell and use it as the row to lookup another cell. I've looked at the google spreadsheet formula documentation and haven't been able to find a solution.
The below pseudocode illustrates what I'm trying to do.
A B C D
1 D
2 =[B1]2 10
3 =[B1]3 9
4 =[B1]4 8
Given the value of B1 is "D" I want cells B2, B3, and B4 to resolve to 10, 9, and 8 respectively.
You might be looking for something like this:
=INDIRECT(INDEX(B$1;1;1)&ROW())
the INDEX(B$1;1;1) gets content of B1 cell (the 1;1 is obligatory parameter, since you can feed INDEX with range and means: 1st row in range;1st column in range which is D
ROW() returns current row number, be it 2, 3 etc.
& concatenates both value, so the result is processed like "D" & "2" => "D2"
INDIRECT(reference) returns reference to a cell or an area (in text form) for which to return the contents.
see https://support.google.com/drive/table/25273?hl=en
Still, depending on what is the original problem, there might be better solutions. Above one is just straightforward answer to your question.
Bearing in mind the correctness and helpfulness of PsychoFish's advice on the use of INDEX() with INDIRECT(), and on the limited usefulness of any one solution for all problems, I think the following formula will work as well in this particular case:
=INDIRECT(B$1&Row())

Resources