I've searched a bit for this issue and maybe I can get help here.
I'm trying to apply a conditional formatting through a named range and I only figured out that "Indirect" plays an huge role on this.
This is the typical table I'm working on, Heading, plus every row has a name with some notes. The table has a named range (Let's call it "Table") assigned to A1:D7 because I have some scripts on GAS that sort the list in different ways based on button pressing.
Since the table is updated pretty often, I just add rows to the "Table" Named range, so the script works fine.
Under the table the typical conditional formatting I use to color the zero or negative cells of both the column B and C but not the column D
Now what I have to do is to apply the whole conditional formatting on only the named range (but just the columns B and C).
I could "Apply to the range" B:C (So I don't have to change it) but under the table there are some other numeric data that I don't want to format.
Using a custom formula =INDIRECT("Table")<=0
doesn't work either since the table has the column Name, plus with some arrangements it colors both the cells B* and C* if the B value is negative and the C is not.
I'll probably add some more stuff since I'm working on it but if someone could aid just on this it would be very helpful
Browsing a bit and understanding that the Conditional formatting just cycle every cell in the range applied and uses the custom formula to check if it should format it or not, I should put it the fact that the cell has to be inside the named range as a condition.
I found this to be useful on a "B2:C" range =AND(NOT(ISERROR(INDEX(INDIRECT("Table"),ROW(B2),COLUMN(B2)))),*condition1_on_B2*,*condition2_on_B2*,*etc*)
(found it on the second post here on this link)
The first conditions returns true when the cell is not inside the named range
NOT to reverse the ISERROR value
ISERROR will return true if INDEX throws an error which is only when the cell is outside the named range
INDEX will attempt to find the cell B2 (or the cell the conditional formatting is checking on every iteration) inside the named range.
It probably is very heavy, performance-wise but for now it works, if there is something else, I'll wait for a better answer.
Related
I want to count the amount a certain text(aus) appears in a column, but I only want to search the rows that have one specific color. I have the two seperate working formulas but haven't been able to combine them succesfully yet. Anybody an idea how to do this :) ? Here are the 2 formulas i have:
=COUNTBACKGROUNDCOLOR("J2:J361";"A2")
=COUNTIF(J2:J361; "*aus")
It appears as though you are using a script to implement your own function of COUNTBACKGROUNDCOLOR(). If this is the case you cannot combine the two functions as it stands since it is a user defined function. As MattKing pointed out maybe count the cells with your data AND the method used to declare the color (checkboxes). Example:
Conditional formatting applied to cells that highlight the cell green if adjacent checkbox is TRUE.
Formula used
Notice the answer is 2 and not 3 because from your formula you are only looking for wildcards before "aus" and Cell D4 contains a "?" at the END ("what is aus?")
We track workshop registrations in a google sheet and I'm trying to conditionally format a range of cells (A7:P14) based on the text in cell E7 (Eng DLO, Eng TBC, Sp DLO, Sp TBC).
I used the formula
=COUNTIF($E7:$E, "Eng DLO")
and A7:S14 turned the selected color (light purple). When I then added conditional formatting to turn dark purple with the formula
=COUNTIF($E7:$E, "Eng TBC")
the color wouldn't change when I changed the value in E7 from Eng DLO to Eng TBC.
I know the issue is that I need it to EXACTLY MATCH the text and I tried incorporating EXACT into the COUNTIF formula, but it would only highlight E7 or just A7:P7 instead of the whole selected range in the conditional format (A7:P14).
Here is a sample sheet with what I am hoping it will eventually look like once I get the conditional formatting to actually work (I removed the conditional formatting). https://docs.google.com/spreadsheets/d/1Bn9FVTHE1OO49p4PKo6j0Qd3c0NX6pUq3vp0pHFNGVI/edit?usp=sharing
Got a couple other issues here:
The 7 is a floating reference, so you need to fix it with $. This is the reason your formula isn't working. In the next row, it would start counting in cell E8. With the $, it works, but less efficiently than it could, which brings me to point 2.
If you're only referencing one cell, just check for equality against that one cell.
To the Eng TBC, you would use
=EXACT($E$7, "Eng TBC")
Just to demonstrate a point, without the dollar sign, the next rows cells would have been checking against this:
=EXACT($E8, "Eng TBC")
Which of course would have been empty.
A More Flexible Solution
Since you probably don't want to keep having to reformat per set of cells, you can use a ROW-based approach to tackle the issue. This one, for example, assumes 8 seats per group.
=EXACT("Eng DLO",INDIRECT("E"&(8 * INT((ROW() - 7) / 8) + 7)))
Every 8 rows, it references the next multiple of 7. (Yes, INT is FLOOR, but shorter.)
I am using Google Sheets and trying to write a custom formatting rule that seems like it should be simple. I am trying to figure out how to conditionally format all the cells in a column INCLUDING AND ABOVE (but not below) the cell that meets my condition.
I've found a lot of things that will format the entire column, but that's not what I'm looking for.
The image below is a basic example that I manually colored in to do what I want.
It's for my budget spreadsheet, where each row is an entry from a particular date. I have an "Agreement" column that is empty except when I enter the date that I reconciled the budget. I want it to color that cell and all the empty cells above it green, signifying at a glance: "everything up to this point is ok/has been checked over". Then as time goes by, and I enter another date several rows below, I want it to extend the colored shading up to there.
I've been searching, but it is hard to articulate this; if I say "until this cell" I get results for "shade cell until text is entered"; any mention of "above" and "below" generally relates to the values in the cells; I've found some things about Indirect but just for a single cell above, not for all cells above the current cell.
Wondering if this is even possible...
Google Sheets example
If you create a conditional formatting rule for column A using a Custom Formula you can use this formula:
=COUNTIF(ROW(),"<="&LARGE(ArrayFormula(IF(ISBLANK(A1:A100),"TRUE",ROW(A1:A100))),1))
The larger the ranges you use, the slower it will be however.
I use Arrayformula() to make my reports dynamic and easier to edit. For example, if I have a Column A with a list o number o blue balls in a set and a Column B with a list red balls in a set, on the cell C1 I can write =ArrayFormula(add(A1:A,B1:B)) and in the Column C will have the total of balls in each set. It would be exactly the same as writing =A1+B1 in cell C1 and dragging the formula down to the last row. Arrayformula() has some benefits, because it will work if some adds or removes rows from the sheet and also it makes the reports way more organized and easier to edit.
Since I´ve discovered arrayformula(), my life has changed, because of the fact that googleSheets expands the formula to other cells. It does not work every time, but the idea of expanding to other cells seems to be possible some way or another, here is a good example of a problem that was not resolved by arrayformula(), but has the same idea.
Keeping that idea in mind, imagine that on Column A there is a list of First Names and on Column B there is a list of Last names. On Column C I want to join this two string using a simples space. The way to do that would be in the cell C1 write =join(" ",A1,B1) and then drag down this formula. This method method however is prone to error since people can add and remove rows, deleting my formula. I want to use a formula that I can write in one single cell and it expands to other cells. I´ve tried =arrayformula(join(" ",A1:A,B1:B)), but it does not work.
Is that a way to do that using =arrayformula() or other native function?
I know I could write a script or custom formula to do that, but this is not my goal here.
I think this formula should work:
=arrayformula(A1:A&" "&B1:B)
In case you want to use a delimiter, you can do the following to have a clean result even though, A or B is not present in some cases:
ARRAYFORMULA(ifna(ifs(isblank(A1:A),,ISBLANK(B1:B),A1:A),A1:A&" - "&B1:B))
I am using Google Docs and unfortunately it does not have a GetPivotData function. As I add more categories and subcategories to my data, the Pivot Table data will be moving (column wise).
So I took the liberty to use formulas and find the Row and Column numbers for all my ranges, so regardless of any new data, my range will expand/contract/shift with the correct data.
Now all I have left is to use a VLOOKUP to feed the data for that specific subcategory. I have a cell that shows the value for my range.... my range is D7:S100... but like I said, if I add one more subcategory, then my range will be D7:T100 and my cell will reflect this change. I want to use this cell reference in my VLOOKUP so it can be dynamic in the range.
VLOOKUP(search_key, range, index, [is_sorted])
VLOOKUP(A1, cell reference, 2, 0)
Can the range ever be a cell reference so my vlookup's range be dynamic?
Use a Named Range. This is available in Google Spreadsheets from the Data menu.
Create a named range to represent your table of data.
Give it a name like myTable or whatever you want to call it, then you can use that Name in the formula:
=VLOOKUP("BOB",myTable,2)
If you need to expand the range, just go back in to the Named Range menu and edit the existing range.
I have not tested it yet but if this is like Excel, then you can even define a named range based on a formula (typically using the Offset, COUNTA, Index and some other functions to dynamically determine the size of the range). This is probably available to Google Spreadsheets but I have only done that in Excel.
Can the range ever be a cell reference so my vlookup's range be
dynamic?
There may be better ways of achieving what you need to do, but the short answer is yes - using INDIRECT.
B1: D7:T100
=VLOOKUP(A1,INDIRECT(B1),2,0)