COUNTIFS ignoring rows based on values in row - excel

I have been struggling with these two problems for the better part of the day. Please see this link to an example: https://docs.google.com/spreadsheets/d/1odU7oqc-WviLzQcghkbYbQG-4DC70-Q_hszb22Chljw/edit?usp=sharing
This is a simplified document I use to see which lecturer (name) has has added which of the 5 documents (on the right) to an online learning environment (one row for each course). The courses can be given in semester 1, 2, or in both. I want to use this document to automatically highlight a name if any of the five boxes on the right is empty if the semester I want to check (Cell D1) is similar to Column E. Furthermore, only the first time a name appears in red, should the e-mail appear so as well.
For this, I of course use conditional formatting (please see those formulas, also pasted in column M (range column C and D) and N (Range column D). N is the white conditional formatting overruling M, in which a N="TRUE" means it is whitened out).
Example 1 (Ans) shows how I intend the programme to work. The first instance shows shows both the name and e-mail in red, later instances do too unless the semester is not similar or all boxes on the right are ticked.
Example 2 (Bertrand) shows the first problem. If the first instance of a red name and e-mail occurs in a semester 'both', the second time the name should be red the e-mail does so as well. This keep occurring until a semester is similar to Cell D1, after which it is normal again.
Example 3 (Carel) shows the second problem. If the first instance in which a certain lecturer occurs all boxes on the right are ticked, the second time he occurs but does not tick all boxes his name shows in red but his e-mail doesn't.
I think problem 1 (example 2) is solved if I can get 'both' to somehow mean both 1 and 2, but I don't know how.
I think problem 2 (example 3) is solved if I can get COUNTIFS to ignore the rows is which all five boxes are ticked.
However, I have no clue how to do this. Is anyone able to help me with either (but ideally both) problems?
Thank you in advance!

I'm not entirely sure, but I think I've understood what you need.
For the first part (where a lecturer has less than all 5 subjects containing 'x' AND where E is either the value of cell D1 or the value of 'both'), try this:
Delete both of your existing conditional formatting rules.
Create a new conditional formatting rule for range = C4:C21 (or perhaps further down your sheet to row 977), with a custom formula of:
=AND(COUNTIF($G4:$K4,"x")<5,or($E4=$D$1,$E4="both"))
The style for the rule should have a red background.
For the second part (updated), this is a bit tricker with conditional formatting but I can offer a solution determined by the value of cells, like you had.
Delete the contents of cells M4:N21 (21 being where you have a formula in the furthest cell).
In cell M4, add the following formula:
=arrayformula(if(iferror(if(ifs(E4:E=$D$1,1,E4:E="both",1)+if(G4:G&H4:H&I4:I&J4:J&K4:K <>"xxxxx",1,)=2,D4:D,),)<>"",countifs(iferror(if(ifs(E4:E=$D$1,1,E4:E="both",1)+if(G4:G&H4:H&I4:I&J4:J&K4:K <>"xxxxx",1,)=2,D4:D,),),iferror(if(ifs(E4:E=$D$1,1,E4:E="both",1)+if(G4:G&H4:H&I4:I&J4:J&K4:K <>"xxxxx",1,)=2,D4:D,),),row($E4:$E),"<="&row($E4:$E))=1,))
It might seem a little complex, but it's done this way to use the functions that are compatible with ARRAYFORMULA so that it will keep working down the sheet as far as you have values in rows.
Now create a new conditional formatting rule for range = D4:D21 (or perhaps further down your sheet to row 977), with a custom formula of:
=$M4=true
The style for the rule should have a red background.

Related

Need a blank cell when IF cell is blank

Long time listener, first time caller...
I'm sure this is simple, but I don't know how to do it.
I am putting together a very simple spreadsheet that will autopopulate the correct shift when a manager is input into a cell. I need to do this cell by cell, because some of the managers overlap shifts.
In place of "name" and "shift" I have the actual manager and shift, but for simplicity sake I have:
=IF(K21="NAME", "SHIFT1", "SHIFT2")
and that works just fine for this because there are only 2 managers with different shifts.
However, when there are no manager names in K21, it still gives me a shift in the other cell.
How do I leave that blank until the manager name is filled in?
(I will also need to have several other "IF" statements in other cells, as there are more managers on those shifts, and nested IF statements are telling me there are too many arguments. Not sure what I'm doing wrong.)
Try using your IF as the second argument for another IF that would check if the Manager cell is empty:
=IF(ISBLANK(K21),"",IF(K21="NAME","SHIFT1","SHIFT2"))
However I would just go with vlookup() like this:
=IFERROR(VLOOKUP(K21,$Q$20:$R$21,2,0),"Not in list")
and then you can have a list of names and shifts and even add a 3rd column with weekend shifts...
So trap the blank first:
=if(k21="","",your if here)
But if k21 has other text then you may need to consider something else, perhaps a list of valid names:
=if(iferror(vlookup(k21,list,1,0),0)>=1,your if here,"")
That list can be a range of cells or just both the names.
See:
=IF(IFERROR(VLOOKUP(K21,Q20:Q21,1,0),0)>=1,IF(K21="Fred","SHIFT1",IF(K21="Julie","SHIFT2","Error1")),"Not in List")
Since you mentioned you'll have multiple if statements, you might consider doing a table and then a lookup. Here's a simple example based on the idea of you have your managers and shifts in column a and b and you type the managers name in cell D2 (or K21 in your case). This would also account for a for blank entry compared to a WRONG entry......
=IF(ISBLANK(D2),"",IFERROR(VLOOKUP(D2,A:B,2,FALSE),"Not listed!"))

Highlight multiple rows based on a single cell with blanks in between conditional formatting triggers?

https://docs.google.com/spreadsheets/d/17CRAqPp_1FXQJAN7KtWMnLvmp54_jvBbrB1rES-yBbM/edit#gid=1220119768
The first sheet is an example of what I'd like, the second sheet is a fresh, un-colored sheet.
I'm trying to highlight 3 rows based on if the first cell located in the first row contains some value.
In this specific case, I have a workout routine type (upper body, lower body, etc) and the routine name on one line. It's rest information the next two lines. I want the rests to highlight with the routine name/routine type.
Since the routine type is rotated, as seen on the example sheet, the 2nd and 3rd cells after the type are effectively blank.
I think the closest solution may be this stackoverflow link, but this is an apps script and I'd prefer a conditional format. While I wait for an answer here, I will experiment with an OR statement, something like
OR($A1="Upper",$A1 - 1= "Upper", $A1 - 2 = "Upper").
Bonus: if possible, I would also like this rule to apply to just two rows but this is not necessary. If you look at the example sheet, "Static Holds" is just two lines.
Edit: This is close to what I want. Except, it only highlights the first cell in the row and not the entire row. Does anyone know how to reconfigure this to work across an entire row?
=IFS($A1="Upper",1,INDIRECT(ADDRESS(ROW()-1, COLUMN()))="Upper",1,INDIRECT(ADDRESS(ROW()-2, COLUMN()))="Upper",1)
try on range A1:F:
=(INDEX(IFNA(VLOOKUP(ROW(A1), IF($A:$A<>"", {ROW(A:A), $A:$A}), 2, 1)))="upper")*($B1<>"")
=(INDEX(IFNA(VLOOKUP(ROW(A1), IF($A:$A<>"", {ROW(A:A), $A:$A}), 2, 1)))="lower")*($B1<>"")
=(INDEX(IFNA(VLOOKUP(ROW(A1), IF($A:$A<>"", {ROW(A:A), $A:$A}), 2, 1)))="back")*($B1<>"")
you can do it with 3 rules offset by a row:

Alternating Color of Rows with Merged Rows in Leading Column - Excel 2016

I'm trying to create an Excel sheet that will be tracking some of our autonomous processes and their access privileges at my company and I've run into an issue with Excel..
I'm trying to alternate row colors, which in and of itself isn't an issue, however the fact that I've got merged rows are giving me issues.
As of right now I've got 5 columns with headers in A through E. Column F is being used for conditional formatting to color the rows. In column F this formula is present:
=MOD(IF(ROW()=2,0,IF(A2=A1,F1, F1+1)), 2)
This works great if I want to repeat the leading Column item over and over, however I'd like to reduce the visual clutter and increase clarity, so I've merged some of the rows in the Column A because multiple rows in B:E correspond to it.
I've merged A2:A4 right now and the formula picks up the A2 and A4 as blank, but A3 (the text in the merged cell is centered) is recognized as different that A2 and A4 because the text resides there. I'll upload an image to give a better idea of what I'm talking about as well.
If anyone can give me a tip on how to alternate row colors with merged cells/rows that'd be great, I've done a lot of googling and searching on stackoverflow, but for the most part I've only found things that pertain to unmerged rows/cells.
Image Example: https://imgur.com/a/UDbRVWA
=IF() Condition that worked for me:
=MOD(IF(ROW()=2,0,IF((A2=0),IF((OR(A1<>0,A2=A1)),F1, F1+1),F1+1)), 2)
There is an answer below with a picture I posted, however, for most situations I would recommend the method suggested by #BruceWayne. It's far more sensible than working with merged cells!
I ended up finding a solution with just some clever working with the Conditional IF() statements. I think the key was taking into account that the Merged Cells that weren't the top (i.e. If I merged A2:A4, A2 is top, A3, A4 bottom) were equal to 0 while the top was set to the value of the text within the merged cell. Using the formula below I was able to achieve the result I was after:
=MOD(IF(ROW()=2,0,IF((A2=0),IF((OR(A1<>0,A2=A1)),F1, F1+1),F1+1)), 2)
And here is a linked screenshot: https://imgur.com/a/gNaC62c
I then just added conditional formatting for every row but row 1: =$F2=1. I'll be hiding column F to make it seem less obtrusive.
For future reference, I would agree with what #BruceWayne mentioned in that a simpler formatting that gets the job done would be preferable. There are many other ways to format this in a way that makes much more sense, but I felt like I was close when I was tinkering with it, so I stuck with it another 15 minutes or so and was able to pull out a usable formatting condition.
Might I make a suggestion? If the merging rows is to increase clarity with repeated entries, perhaps we can use another Conditional Formatting rule to make it more legible.
Say you have data that looks like this:
But, we don't want to see <Process #> duplicates in the A column. We could merge these cells and center it along the rows. But again, merging cells is generally frowned upon I've found. (It makes it tricky to format, conditional format, copy/paste, do any VLOOKUP()/Index/Match, etc.)
First, let's get the rows alternating colors. I'm using fill of RGB(183, 255, 253):
New Rule 1 -
Formula: =MOD(ROW(),2)
Applies To Range: $A$2:$E$9
Format: Fill with color RGB 183, 255, 253 (...or whatever you want, just note the RGB for later)
Now, we get this:
Okay, making progress. Now, let's work on hiding the duplicate values in column A.
So, let's apply some more Conditional Formats. We'll need two for column A, one to set the font to White, one to set the Font to that blue fill color.
New Rule 2 -
Formula: =AND($A3=$A2,MOD(ROW(),2)=1)
Applies To: =$A$3:$A$100
Format: Font --> Color --> RGB(183, 255, 253)
New Rule 3 -
Formula: =AND($A3=$A2,MOD(ROW(),2)=0)
Applies To: =$A$3:$A$100
Format: Font --> Color --> White
Now we have:
IMO, we can do one more thing to clarify the breaks in Processes:
New Rule 4 -
Formula: =$A2<>$A1
Applies To: =$A$2:$E$100
Format: Border --> Top Border
Now, we have a nice new CF table.

Copy data from conditional formatted cells to new tab based on the conditional formatting color in Excel

Okay so I'm new to all this- please help me if there's a better way to do this... currently trying to make changes to an existing spreadsheet and I can't figure out how to accomplish what I want...
Tab 1 accounts for different numbers and their assignments, Tab 2 rearranges that data for a printable page, and Tab 3 has a list of all the numbers we have to account for, and currently uses conditional formatting to do so. (Green if the number is accounted for on Tab 1, Red if not)
What I am trying to accomplish is create a list of all the numbers NOT accounted for (Red conditionally formatted cells on tab 3) to show up in any form on Tab 2. I started messing around with the =mycolor and IF functions, but I found that only works with explicit formatting of the cell, not the conditional formatting I am using to account for the numbers.
Do I need to change how my spreadsheet is accounting for the numbers from Tab 1 instead of conditional formatting? If so what would be the best way to go about this? If there's a way to do this with conditional formatting, how would I go about copying data based on the conditional formatting of certain cells?
Also, ideally I want this to be done without having to play a macro. I'm trying to make this as stupid simple for the end user as possible... but if there's no way to do it without recording a macro then that's what I'll end up doing.
Thanks a bunch in advance...
What I would do is add a column to tab three that is a missing/not missing column (=column C in my mock up below). Missing = 1 accounted for =0. (That can either be achieved by the same formula as used to give the red/green OR a vlookup() function). Therefore for each red row there will be a 1 alongside.
Extending that, as per my comment... index the missing values (col A=):
=IF(C3>0,SUM(C$1:C3),"")
Now use a new pair of columns to grab the missing values
And use a lookup function to line up the missing values (col G)... I only went up to 5 (col f)
=IFERROR(VLOOKUP(F3,A$3:B$6,2,FALSE),"")
THANK YOU for your help Richard!
With some changes, the Vlookup function you gave me (in Column E) worked fine:
=IF(ISERROR(VLOOKUP(E2,hiddenradios,1,FALSE)),"1","0")
And adding the second column(s) and the sum function for values was a really helpful idea: (column H)
=IF(VALUE(F2)>0,SUM(G$2:G2),"")
For whatever reason I couldn't make vlookup work, even with the column relocated to the left of the number I was trying to return, but I was able to do the same thing with an INDEX/MATCH formula in column J:
=IFERROR(INDEX(E$2:E$100,MATCH(I2,H$2:H$100,0),1),"")
Not quite as simple as yours, but you set me on the right path with adding column(s) and I wouldn't have figured it out without your help... thanks again!
enter image description here

Assign a value to a variable [Excel]

I'm making a basic inventory list for my place of work and want to make it easier for future inputs and changes. So far I have inputted all of the model numbers for our inventory, and I was wondering how I could assign a price to the model number, so that it automatically fills it into the cell two cells right. I'm also working with around 50 model numbers, so it would be a lengthy function.
Example:
B E
778740 125.99
778739 120.99
778740
Is there a way that the second "778740" could be automatically filled in? I'm fairly new to excel and I can't find this problem, although I know it is very simple and exists. Even if some one could link me it that would be very much appreciated. Thank you!
Suppose your headers are in row 1, model numbers in column A and prices in column B. You could use the following formula in cell B3 and drag it on down as far as you need. Then what you fill in in column A matches something above, the cell next to it will automatically populate. And otherwise it stays blank, letting you know it is on you to fill it in (though once you do, the formula will no longer be there, so if you later fill in a match above, the magic is gone).
=iferror(indirect("B" & (1+match(A3,A$2:A2,0))),"")
The match function returns an error if nothing is found, and ifError will handle that by leaving your cell blank. If a match is found, we get the value from the corresponding row in column B.

Resources