can i block others from merging any cell without protecting them - google-apps-script

The title says everything, I just need another user of my sheet to fill cell without giving them the right of merging any cell.
I have tried I'm going to use the filled cell in one other sheet using index formula and if they merge cell I don't get the right result.
<== C3&" "&D3&" "&E3

Change F6 to:
=C6&" "&D5&" "&E5
The merged cell references the first merged row number.

Related

Sheets lookup on conditional highlight colour

Is it possible to check a cell's conditional highlight colour and act accordingly?
I have a list of Names where some people belong to the "Yellow" team and some the "Pink" team. The Yellow team get more points allocated depending on their level (Cell B3).
Referring to the screenshots attached, I can't work out how to direct the lookup to the appropriate column of points per level in 'Sheet2' relative to the chosen Name. Conditional highlighting (see screenshot) sets the cell colour according to the Name input into cell B2.
Cell B6 contains the following formula:
=vlookup(B3,Sheet2!A1:E11,match(B2,Sheet2!A1:E1,0),)
The formula worked when the reference table had Column B named as "Bob" but that is not what I want.
I want the B6 formula to realize which colour team the B2 Name is and pick from the appropriate data set in 'Sheet2'.
Any help appreciated if it is at all possible to lookup against cell highlight conditions.
Thanks!
There's no direct way of doing it. You might want to use the getBackground() function in Google apps script, but I don't think it's worth using scripts for this case. That would mean making the thing more complicated and less maintainable.
The easiest way you can achieve it is by using a helper cell.
You'll need the two teams listed in two columns. I'll assume to make things simple to have the two ranges E2:E30 for yellow names and F2:F30 for pink names
Add Color in cell A4 and the following formula in B4:
=IF(ISERROR(MATCH(B2,E2:E30,0)),IF(ISERROR(MATCH(B2,F2:F30,0)),"No color","Pink"),"Yellow")
You could then use the result of cell B4 for the VLOOKUP in cell B6.
The added advantage is that you wouldn't need that many conditional formatting rules: you can simply compare the color in B4 and assign a conditional formatting rule accordingly in B2. It's way more maintainable and less error-prone.
Using Named Ranges for conditional formatting (no script, no helper cell)
Since Francesco's excellent proposition on using formulas instead of a script is your choice, you could also try the following.
Turn your team ranges to Named Ranges (by going to Data>>Named Ranges from the top menu) and name them e.g. yellow and PINK
Apply conditional formatting to your data validated cells (B3:E3) by using these two formulas (under Custom formula is found at the end of Conditional formatting rules):
=REGEXMATCH(B3,""&JOIN("|",FILTER(INDIRECT("yellow"),INDIRECT("yellow")<>""))&"")
and
=REGEXMATCH(B3,""&JOIN("|",FILTER(INDIRECT("PINK"),INDIRECT("PINK")<>""))&"")
(Make sure you adjust your ranges according to your data)
Advantages:
It is your original cells that get color coded.
Named Ranges can be placed anywhere, on any tab and can grow to your needs.
You do not need the extra helper cell.
Make a note:
We must use INDIRECT when using named ranges with conditional formatting for the function to work.
We must also surround the named range with double quotes "". So, to refer to the named range yellow we use INDIRECT("yellow).

Having one "base" formula re-used in and updating other cells

Here's a tough one to explain. Tough one to wrap your head around.
I have a column of formulas that, when updated, should change the formulas of other columns.
For example, you have the below spreadsheet:
When you copy column A, and paste it to column D, the formulas would respectively change to =D1+1, =D1*5, etc. That's great. But now I want to change for example cell A2, from =A1+1 to =A1+9. How can I get the rest of the cells to change from e.g. =B1+1 to =B1+9.
How can I "link" one cell's formula to another cell's formula? How can there be a "base" or "primary" or "master" cell which other cell's reference for their formulas, and all "slave" cells change dynamically when the "master" cell changes?
Putting =A2 in cell B2 wouldn't work since I'm not copying/pasting values, but trying to get the base formula updated automatically, but still changed dynamically for it's own respective column.
Ideally, this is done with a formula, not a script, and all on the same sheet.
The closest I've gotten is this:
A2 = column1+1
D2 = =VALUE(SUBSTITUTE(A2,"column",SUBSTITUTE(ADDRESS(1,COLUMN(),4),"1",""),1))
The thought here is to replace the word "column" with the letter of the column the formula is in, then convert that to a working formula. Except the outcome as it is spits out D1+1 which is SO CLOSE, that's what I want! But it's a string, not a formula
google-spreadsheet
=ARRAYFORMULA(A1:D1+1)

Conditional formating based on adjacent cell using script

I have a spreadsheet that looks like (but much larger):
Both the student names and the house assignments are pulled from other sheets.
I am looking for a google script that would conditionally format a student name based on the house they are assigned to. The house assignment will always be listed in the cell to the right of the name.
I realize this can be done with conditional formating (For instance: Custom formula =B3:B4="6-Blue"), but it becomes an arduous process because I have to go into each vertical range individually to make a change if the house name changes. With a google script, I could find and replace all instances of a house name.
Something like Eric Koleda's answer may work, but I am unsure how to reference the ranges and add multiple values to search for.
You can still do this with conditional formatting!
You can set up conditional formatting on a per column basis, you don't have to change the formatting, only the name of the color in your house column.
Conditional formatting formula: =ISNUMBER(FIND("Red", $C4))
Conditional formatting range: B4:C
This will try and find the text Red within all cells in Column C starting at C4. If Red is found in a cell, FIND() will return the index of Red, if it doe snot find Red is returns an error. You can check this with ISNUMBER(), which returns true or false if the value is a number or not.
This will color the adjacent columns on that row within the range. ie. A range of B4:C will color the cells in column C and B, a range of just B4:B will only cause the cells in column B to be colored.
You only need to setup one conditional formatting per color, per set of columns that you have. After that, just changing the colors under your houses will change the formatting.
Here is an example sheet I made for you: Example Google Sheet
Picture of Sheet with formatting:

Make a script to conditionally sum cells

I want to make a small script in google script editor for spreadsheet that sum's cell's according to other cell. Something like:
IF (A2:P2)==Q2{
SUM (A3:P3)}
I want to sum the cells that contains a certain character. Here a example of my question. How can I do it?
You don't need a script for this. You are just describing SUMIF which
Returns a conditional sum across a range.
Using a copy of your sheet I got your desired result with this formula
=sumif(B3:P3,"A",B4:P4)
Then you could use absolute cell references to make it easier to copy this down.
=sumif($B$3:$P$3,"A",B4:P4)
Question has changed
Since you have changed the source sheet you are asking a related but different question. Same as before though... you don't need a script for this. You can use COUNTIFS(). You have two counting criteria. Count if the cell contains a letter and count if the header row contains a number. We break this up into two conditional sets.
=COUNTIFs(B3:P3,Q2,B2:P2,1)
Q2 is the cell that contains "A" and the 1 is the header columns we are counting.
In order to move this down the row by simple drag and drop you still need to use absolute reference in the cells that are not moving. Q2 and the header row specifically.
=COUNTIFs(B3:P3,$Q$2,$B$2:$P$2,1)
To make the sum (row per row) of all the columns that have 'A' in the header, try in Q4:
=ArrayFormula(MMULT(N(IF(B3:P3="A", B4:P11,)) , transpose(N(B3:P3="A"))))
Change 'A' to 'B' etc.. for 'sum of all B'
If you want the result to auto-expand when new rows are added use the formula like this:
=ArrayFormula(IF(LEN(A4:A), MMULT(N(IF(B3:P3="A", B4:P,)) , transpose(N(B3:P3="A"))),))
EDIT: based on new info, I updated the formula to:
=ArrayFormula(MMULT((B2:P2=row(B3:B10)-2)*(B3:P10="A"), TRANSPOSE(COLUMN(B2:P2)^0)))
Example sheet
Of course the SUMIF() proposed by Matt will equally work (and is definitely a lot simpler). To drag the formula down, use the dollar signs to 'freeze' the header row, e.g: sumif($B$3:$P$3,"A",B4:P4)).

I can't merge certain cells in SSRS

I have added a row into my report by right clicking the top row and selected add row above. Then when I try and merge all the cells in the new row it doesn't give me the option when I have selected all the cells and right click.
I can Merge 2 or 3 cells but not the whole thing.
My question is why cannot I not merge all the cells? Is there something in the a certain cell I can't see or a creation property that needs to be changed.
Thanks
There seems to be an invisible lines between the row headers and the data, and also the column headers and the data. You cannot merge across these lines.
The solution is to keep you groups and delete the row and column headers. You can put the header rows inside the data area and you can merge cells too.
Sometimes you can only merge the cells from a row if you merge the cells from the row above.
_____1__________2_________3____
A |__________|__________|_________|
B |__________|__________|_________|
Sometimes you can only merge B1-B2-B3 if you merge A1-A2-A3 first.
This problem occure with grouping. You cannot merge across group lines. I have not had a problem merging when there is not a group. There is not a way around this.
if you're trying to create a header row for the whole table. you can create a separate table with 1 column and 2 rows and insert your table into the 2nd row of the new table. the 1st row can then be used as a header
The left-most column has been auto-added as a group, so it can't be merged with cells to the right. But you can delete that column and keep the grouping.
What I do is click on the second column (inside the grouping), then 'add column to left'. Then copy all of the Group fields from the left-most column into this new column, then delete the left-most group column. You should now be able to merge the cells.