Hide a rows and/or columns using formulas - google-sheets

Is it possible to conditionally hide rows and/or columns using formulas but NOT the API?
Example:
=IF(A1=0,HIDEROW(1),SHOWROW(1))

HIDEROW and SHOWROW are not native Google Spreadsheets functions and with that and using formulas but NOT the API I am not sure what you want, though the answer is likely ‘No’ regardless.
Alternatives may include a Google Apps Script, hiding the row content rather than the row itself (say with conditional formatting) and filtering the data – ie a copy of only the part you want visible. This might be with FILTER. For example with 0 and 1 alternating in A1:A4 of Sheet1 and B1 series filled in B1 to B4 then in A1 of another sheet:
=IF(F1=2,FILTER(Sheet1!B1:B4,NOT(ISBLANK(Sheet1!A1:A4))),FILTER(Sheet1!B1:B4,Sheet1!A1:A4=F1))
Should show B1 … B4 in that other sheet when F1 in that sheet is 2, just B2 and B4 when 1 and just B1 and B3 when 0.

Related

How to check if a row has data and conditional format from there?

I'm trying to code a Google Sheet to check if a row has any data in it, and then use conditional formatting to color-code another cell in that row. How could I do this?
Screenshots are here. The idea is that the cells in column B will turn red if there is any data in the same row. So in this example, B2 would stay green, B3 would turn red (automatically, with no text input), and B4 and B5 would stay blank, because there is no data in that row.
This sheet is linked to a Google Form, so it needs to be able to update automatically.
(I'm a beginner to Google Sheets, so I'm not familiar with the necessary code at all.)
Edit: Here's a copy of my sheet.
try simple custom formula:
=A2<>""
spreadsheet demo

Make AVERAGE only for numerical values

I have some problem to build a dynamic AVERAGE in Google Sheets.
What I have here is this configuration.
I have a Cell A1, B2 and C3 that have another formula (like IF) that can return 2 different values: Numerical or N/A.
Then I have Cell D4 which keep the AVERAGE of cell A1, B2, C3.
The problem is that even if one of the above cells (A1, B2, C3) has N/A even the AVERAGE results returns N/A.
Are there any possibilities to make the AVERAGE working by ignoring N/A or any kind of texts and working only with Numbers?
This is the formula I have at the moment: =AVERAGE(A1, B2, C3).
you will need to wrap it into IFERROR like:
=AVERAGE(IFERROR(A1), IFERROR(B2), IFERROR(C3))

Google Spreadsheet: E2-F2 even if i move the rows

I'm having an issue with google spreadsheets. I want to... have Cell C2 always contain the difference between cell E2 and F2 even if I move the row (i don't want the formula to adapt to that change of rows, the formula should still be E2-F2); so let's say E2 contains 5 and F2 contains 3, C2 would display 2. So let's say I switch row E and row F. Right now the result displayed would still be 2, and the formula in cell C2 would've changed to F2-E2. What I want is the formula not to change, and the result displayed would be -3.
=INDIRECT(E2)-INDIRECT(F2) didn't work for me - it gave me a reference error.
The INDIRECT function expects a string parameter. So you would need to write
=INDIRECT("E2")-INDIRECT("F2")
But the better way to solve your problem would be to use absolute references
=$E$2-$F$2

Freeze formula that references cell in another sheet

I'm working in a Google Sheets document that has two sheets, Sheet1 and Sheet2. Sheet2 has a cell, A3, with the formula =Sheet1!A3. This pattern holds throughout the column – e.g. A4 in Sheet2 has formula =Sheet1!A4, etc. Without getting into too much detail of the why, essentially the A column in Sheet1 is to be reflected in the A column of Sheet2. My desire is that when Sheet1 is updated, those changes will be reflected in Sheet2.
The problem is that when I add/delete entries into/from column A in Sheet1, Google Sheets automatically updates the formulas in Sheet2 in a way I don't want it to. For example, say I insert a cell above A3 in Sheet1, so that there is now new information in A3 and the previous A3 is now shifted down to A4. When I check out Sheet2 I want the new A3 from Sheet1 to be reflected in Sheet2's A3. However, the formula in Sheet2's A3 cell has now been updated to =Sheet1!A4 (so that Sheet2's A3 still shows the information from Sheet1's original A3), and all subsequent cells have been shifted by one as well. I can see a reason for this auto-updating functionality, but it is a hinderance in this case.
In looking up a solution, I've found out about absolute reference, i.e. changing the formula in A3 to =Sheet1!$A$3, but this unfortunately does not help in my case.
Is there any way to prevent this autoupdating of the cell reference?
On Sheet2 use INDIRECT. Example
Add the following formula to Sheet2!A1
=INDIRECT("Sheet1!A:A")
The above will not be "affected" by row/column changes made into Sheet1 because it doesn't make a direct reference to rows/columns on Sheet1.
Non-volatile equivalent of INDIRECT could be INDEX.
=index(Sheet1!a:a, 3)
Unfortunately, filling down for index(Sheet1!a:a, 4), etc is difficult if not impossible. You could represent the 3 with a row reference to a worksheet that will never have rows deleted; e.g. row(sheet2!b3). That shouldn't change unless you add/delete rows on sheet2 while allowing add/delete rows on sheet1.

Sparkline in every row with only one arrayformula google sheets

I would like to plot sparklines (barchart with the value to show in B-row and the max-value in die C-row: see linked file) in every cell from A2 to A5 using ony one arrayformula (=ARRAYFORMULA( ...) in A2 which can plot spakrlines in every cell from A2 to A5.
Link to file: sparkline arrayformula
Thx for any help,
Gerd
SPARKLINE does not work with arrayformula. I think the best you can do is put this in A2 and drag it down past A5. It will pick up new data.
=iferror(SPARKLINE(B2,{"charttype","bar";"max",C2}),"")
Hmm
Make a blank column A:A.
=ARRAYFORMULA(IF(ISBLANK($A$1:$A),"", SPARKLINE({0,1},{"color","#ddd"})))

Resources