Read range value from a STRING cell - google-sheets

I have many formulas (20+) using data from some range in a single spreadsheet.
The problem is that when I copy those formulas to some other part of the spreadsheet to handle another range, I have to manually modify each of them to adapt them with the new range value !!
What I'm looking for is -for example- to enter the range value in one cell as a string, so all my formulas will automatically use that string value as a range.
In other words, let's say that my formula in cell A2 is calculating the sum of a range using =SUM(C32:C45)
If cell A1 contains the value C32:C45 I want to modify my A2 formula to use that range.
I tried =SUM(INDIRECT(ADDRESS(row(),column()-1))) but it didnt work... What Am I missing ?
Any other ideas that helps avoiding the multiple editing of each formulas are welcome (hopefully using native google-spreadsheet functions only -no scripting unless it's the only way :< -)

When in ColumnA column()-1 won't suit. In keeping with the OP's approach it seems:
=sum(indirect(indirect(address(row()-1,column()))))
would suit though perhaps also the simpler:
=sum(NamedRange1)
where NamedRage1 is C32:C45.

Related

How do I conditionally format if value extracted is > number value?

I have a use case where I need to conditionally format a cell if the extracted value from this formula is greater than 5.
=trim(MID(C3:AZ,FIND("-",C3:AZ)+1,FIND("pts",C3:AZ)-FIND("-",C3:AZ)-1))>5
When I lock the cell references, I still don't get any conditional formatting, even though it accepts the formula:
=trim(MID($C$3:$AZ,FIND("-",$C$3:$AZ)+1,FIND("pts",$C$3:$AZ)-FIND("-",$C$3:$AZ)-1))>5
When I do the formula referencing a single cell, I get the expected output:
I've made an example Google Sheet for reference, if you'd like to take a look at the sample dataset.
Any help/advice you all could provide would be greatly appreciated.
Thanks!
Try this formula. The way conditional formatting works is if the range for conditional formatting starts on A3, then you can put that one cell as the checking value, and the spreadsheet is smart enough to then check each cell in the range separately. I put a value around it as well since "trim" makes it a text instead of a number.
=value(trim(MID(A3,FIND("-",A3)+1,FIND("pts",A3)-FIND("-",A3)-1)))>5

Google Sheets Recursive Array Formula

I'm trying create a list of sequential dates from a set date to the most recent date in another column.
=ARRAYFORMULA(IF(OR(A2:A=MAX(C:C),A2:A=""),"",DATEVALUE(A2:A+1)))
I use MAX() to find the dates most recent date in column C. What I'm trying to get this formula to do is to recursively check the date in the cell above to determine if the max date has been reached. I've made sure A2 already has the set starting date.
The output is in only one cell though and I don't know why.
Thank you for the help.
What appears to be troubling your current array formula is that as defined it goes on forever and is self-referential. There may be a way to make it by setting preferences to be iterative and helping it interpret getting to repeated cells with "" as convergence.
Here is a way to sidestep those issues. You can bulletproof it more (for example, by encasing it in an IFERROR), but basically you can calculate exactly how many entries you need, and then set your range in the Array formula accordingly. In A3 you place the following:
=arrayformula(DATEVALUE(Row(indirect("A3:A"&(max(C:C)-A2+2)))+A2-2))
which will construct the exact range you want, then calculate each entry with an explicit rather than recursive formula.
EDIT: the above implementation assumes you need at least 2 dates. You can handle that case and other weird ones with the following, less readable formula, =if(max(C:C)>A2,iferror(arrayformula(DATEVALUE(Row(indirect("A3:A"&(max(C:C)-$A$2+2)))+$A$2-2))),"")

Google Sheets - Lookup with Mulitple Criteria

Trying to work out formula to look up record from a 2nd Tab based on 3 cell values in current Tab.
Shared example of my sheet here:
https://docs.google.com/spreadsheets/d/1RgOn6KoFpcwc_puxdvYO5NK12RwlRMUBfUdLntQSiC4/edit?usp=sharing
Any help or pointers appreciated. Have been googling for days but can not find specific answer to this situation. Combined with me being some-what a novice isn't helping.
You can concatenate the cell values in the Summary sheet, and also the corresponding values in the Parts sheet, and do an index/match (could also use VLOOKUP with an array expression like {B:B&C:C&D:D,A:A} if you wanted to).
=ArrayFormula(iferror(index(Parts!$A:$A,match($A3&C$2&B$1&C$1,Parts!$B:$B&Parts!$C:$C&Parts!$D:$D,0))))
entered into C3 and pulled across and down.
Note that I have included B1 & C1 in the concatenation. This is because of the merged cells - the right-hand cell in each merged pair in the Section cells will always be empty, so this guarantees that a non-empty string will be used.
In principle you could develop a single array formula to fill all the cells, but that would probably be overkill.
Here is the Vlookup version for comparison
=ArrayFormula(iferror(vlookup($A3&C$2&B$1&C$1,{Parts!$B:$B&Parts!$C:$C&Parts!$D:$D,Parts!$A:$A},2,false)))
For the record, a single array formula wouldn't be any longer:
=ArrayFormula(iferror(vlookup(A3:A5&B2:I2&A1:H1&B1:I1,{Parts!B:B&Parts!C:C&Parts!D:D,Parts!A:A},2,false)))

Condition Formating, how to highlight a cell when it dosn't include text in a list

Good Day
I am wondering what custom formula i should use in condition formatting to highlight a cell when it doesn't include a "part name" i have in a list on sheet2
I want Cell A4:A1000 to turn orange when the text in the cell next to it "is not" on a list in Sheet 2 A2:A100
let me know what additional information you need... sorry
Im currently stuck with something like this....:
F4=indirect('Auto Fill'!A2:A343)
but i need it to not be on the list... which is something that's missing from this formula as well... so maybe:
F4= ISNOT indirect('Autofill'!A2:A343)
This is the inverse of your request - I'll leave it as an exercise to the reader how one would get the opposite.
Basically, you want check if the value of some cell is in the list of valid values. If you were computing this as a sheet value, you would use =COUNTIF. For conditional formatting, the same applies:
=COUNTIF({LOOKUP_RANGE_ABS_REF}, {VAL_TO_CHECK})
=COUNTIF($D$2:$D, B2)
Here's the formula in action:
Note that T-3000 and wheels are not in the "Part List" column, and thus do not match.
Comparing to different worksheet within same workbook
If the data to be compared against is not in the same worksheet, the range reference {LOOKUP_RANGE_ABS_REF} must be wrapped in a call to INDIRECT(), i.e.
=COUNTIF(INDIRECT("{OTHER_WORKSHEET_NAME}!{LOOKUP_RANGE_ABS_REF}"), {VAL_TO_CHECK})
=COUNTIF(INDIRECT("some sheet name!$A$2:$A"), B2)
As per official documentation,
Formulas can only reference the same sheet, using standard notation "(='sheetname'!cell)." To reference another sheet in the formula, use the INDIRECT function.
This is also noted in several other SO questions (albeit using different core formulas besides COUNTIF):
https://stackoverflow.com/a/25753889
https://stackoverflow.com/a/28910087
https://stackoverflow.com/a/36684815
https://stackoverflow.com/a/37634170
(I'm sure there are more.)
Missing from those answers is the caveat that the indirection you've just added is not robust to changes to the value of {OTHER_WORKSHEET_NAME}, e.g. you (or some other editor) changed the actual name of the worksheet.
Unlike traditional entered-on-the-worksheet formulas, there is no "run-time" reference link that will update the static text value you had to enter when you created the Conditional Format rule. This lack of reference-updating is actually one of the useful features of INDIRECT(), so don't expect it to ever change.
Furhtermore, the reference break will not be immediately evident. Any items that were added to your formatted range after the name change had their format computed using the broken reference, but any items added before the name changed will keep their current format. Only when the actual range that is wrapped by INDIRECT is edited will any pre-existing conditional formats be recomputed. Thus, you may not notice that the sheet was renamed until you add a new valid part to the list.
Quick kludge, import what you need (I gave it the name List) from sheet2 (you'll have to grant permission), Select ColumnA and apply a CF formula rule of:
=and(A1<>"",iserror(match(B1,IMPORTRANGE(" k e y ","List"),0)))

Using IMPORTRANGE, INDIRECT, and CONCATENATE together

I have a sheet that pulls numbers from several different sheets to amalgamate numbers. Each week, a new sheet is added to the source files, all with the same name. I'd like to update the amalgamated sheet by changing one cell instead of many.
When the tab is located in the same Google sheet, this is easily done with INDIRECT.
Right now, the formula in the amalgamated sheet is:
=IMPORTRANGE(M4, "Aug29!$F$2")
That formula is on each line to pull from several different sheets:
=IMPORTRANGE(M5, "Aug29!$F$2")
=IMPORTRANGE(M6, "Aug29!$F$2")
and so on.
Each week, the "Aug29" changes to the new date - "Sep5", "Sep12", etc.
What I'd like to do is use INDIRECT to pull that part of the equation in (from cell Z1) so that I don't have to update each formula.
I was thinking I could use CONCATENATE to create the "Aug29!$F$2" portion of the formula with INDIRECT:
=IMPORTRANGE(M4, CONCATENATE(INDIRECT(Z1), "!$F$2"))
The problem is, the IMPORTRANGE formula requires quotations around the range string, and I can't figure out how to add them.
Weird problem, I'm sure, but wondering if there's anyone with a solution?
Short answer
Use =IMPORTRANGE(M4, CONCATENATE(Z1, "!$F$2")) or =IMPORTRANGE(M4, Z1&"!$F$2")
Explanation
INDIRECT requires a string that represents a cell or range references, like "Z1" but it will increase unnecessarily the complexity of your formula.
If Z1 has the name of the sheet, then just concatenate it by using CONCATENATE, CONCAT or &
UNTESTED. Please try something like:
=IMPORTRANGE(M4,Z$2)
with in Z2 something like:
=Z1&"!$F$2"
In other words, I think your IMPORTRANGE does not like INDIRECT.

Resources