Conditional formatting row referencing cells in another row - excel

I'm creating a list, and wish to link items in that list...
Here's a hypothetical setup to relay the basic issue:
column B is merely a list of successive numbers (1 through 1000)
column K receives a value of "O" or "C" depending on whether the issue is open or closed
column L receives a numerical value that references the value of column B in another row.
I want column L to link one row to another.
ex:
Value of B1 is "1" --->we'll call this "row 1"
Value of B2 is "2" --->we'll call this "row 2"
If L2 is "1", I want row 2 to be linked to row 1.
Then, if K1 is "O", I want no action to be applied to row 2.
However, if K1 is "C", I want row 2 to be highlighted.
Essentially, we're creating finish to start links for tasks.
Therefore, this should be able to have several rows with column L values all referencing the same column B value, so when that row is changed to closed/"C", those several other rows all become highlighted.
I've been digging for a while, so sincerely appreciate the help.

You may try something like this...
Highlight the whole columns say B:L and make a New Rule for conditional formatting using the formula given below and set the format as per your choice.
=INDEX($K:$K,MATCH($L1,$B:$B,0))="C"
See if this is what you are trying to achieve.

Related

Pull cell data while other cells within row match a string

I'm using google sheets for a work project, and I'm trying to pull data from a cell that is in a row with 2 cells that match what I'm looking for.
For example: I have 8 columns and 5600 rows in sheet 2. I want to pull the data from column "D" but only if the data in columns "A" & "C" match what I'm looking for. Say column "A" is filled with days of the week, and column "C" is filled with first names, and column "D" is filled with an ID number. I want the ID number from column "D", but only from the rows in which column "A" = "Thursday" & column "C" = "Jeff". There will also be some rows that share columns "A" & "C", but have a different number in column "D", and I would like to pull those as well.
Here is my attempt where I was able to grab the day of the week:
=INDEX('sheet2'!A:A,MATCH((INDIRECT("RC[-5]",0)),'sheet2'!C:C,0),)
(the indirect function is there because the first name I want to match for is always going to be 5 cells to the left of where this function is)
And here is my attempt where I was able to grab the ID number:
=INDEX('sheet2'!D:D,MATCH((INDIRECT("RC[-5]",0)),'sheet2'!C:C,0),)
So, I want to be able to call the second function above, but only if the first function evaluates to "Thursday", for example.
To me this boils down to two different problems
Q1) A multiple criteria lookup (INDEX+MATCH)
Q2) Returning several values when multiple rows match your criteria
Assume that the weekday is 6 cells to the left of your function and the first name 5 cells to the left. I have also restricted the range from searching the whole column. Adjust as needed, but the complete column is a bit too much for Excel to handle.
A1) This simple lookup will deal with the multiple critera issue, but doesn't fetch duplicates of the name and weekday combination.
=INDEX(sheet2!D2:D12,MATCH((INDIRECT("RC[-6]",0)&INDIRECT("RC[-5]",0)),sheet2!A2:A12&sheet2!C2:C12,0))
A2) This formula would list all the results in the same cells delimited by a comma, looking like this "121208,445555,445553", not on separate rows.
=TEXTJOIN(",",TRUE,(IF((INDIRECT("RC[-6]",0)=sheet2!$A$2:$A$12)*(INDIRECT("RC[-5]",0)=sheet2!$C$2:$C$12)*(1-ISBLANK(sheet2!$D$2:$D$12)),sheet2!$D$2:$D$12,"")))
Edit after comment feedback: Some versions of excel requires you to apply this formula with Ctrl+Shift+Enter instead of just Enter for it to work properly.
If you need to have all the matches for a pair of criterias stacked on separate rows I would recommmend that you check out the Power Query tool (native in the latest versions of Excel). This would be a relatively easy task for PQ to handle by merging tables with join kind "Left Outer".

How to increment duplicate values from 1 to n by criteria?

let's say I have a list of duplicate values in a column such as:AAABBAACABC. ...AAC. Then I want Excel to Rank respectively the first A as A1,the first B as B1 the second A as A2 and the second B as B2 and so forth until the A(nth) and the B(nth). And any additional A should automatically Rank as A(nth+1). Same thing for B C etc.
note that I should be able to enter any new value such as X that will automatically Rank as X(nth+1) or X1 if it did not exist in the table before.
Hoping that I made myself understood. I am waiting for anyone to help me. VBA or array formulas I have no preference once I can realise what I want.
Note that I found a way by sorting them in accending order but it can't match for any additional value at the end of the data base.
Thanks.
I am assuming your data is in Column "A". Enter the formula in Column "B" and copy the formula till the row you want.
=A1 & IF(A1="","",COUNTIF($A$1:A1,A1))

Hierarchical auto-numbering in Excel

Is there a way to get auto-numbering in column "B" of the form given in the pattern below without VBA? (Densities of "A" and "B" are arbitrary; the only rule is that it cannon be two and more A's 'in a row', and "A" always goes first.)
A
B 1
B 2
B 3
A
B 1
B 2
A
B 1
B 2
B 3
Some auxiliary calculations (columns) if needed are fine.
P.S. The extension of the task is here.
Hi Garej: Based on the example you provided you could accomplish this with an "IF-THEN" formula in excel. Just put your letters in a blank excel document, paste the formula in cell B2, and you should be good. You need hardcode ="A" in the formula to be whatever "A" is. Here is the formula:
=IF(A2="A","",IF(A2=A1,B1+1,1))
If you don't want to hard code the ="A", you could also change the beginning from:
A2="A"
to
A2=$A$1
which would allow you to have a dynamic value instead of "A" so the full code would be....
=IF(A2=$A$1,"",IF(A2=A1,B1+1,1))
The logic behind this code is as follows:
Look at the letter in the current row...
IF the letter in the current row is "A" [or matches the contents of $a$1], then leave the number blank.
IF the letter in the current row is the same as the letter in the previous row, then add one to the number in the row above.
IF the letter in the current row is different than the row above [and is not "A" or $A$1], then start over at 1.
Put the following starting in cell B2 (B1 can be hardcoded as 1):
=IF(A2="A","",if(A1="A",1,B1+1))
This simply looks at the prior row - if Column A in the prior row said "A", then we know that this current row is a new one starting at 1. If it wasn't "A" in the row above, we know this is a continuation of the current count. It first checks the current row - if the current row is "A", we know we want this one to be blank.

Find the difference between data in 2 columns in Excel

I have 2 sets of data. I put it in Excel e.g. column A and column B. Now I want to know which data from B is part of column A. I run this formula =IF(COUNTIF($A$1:$A$327238,B1)>0,"Exist", "Nope")
Then I 'filter it and look only 'Exist'. Based on that I know that all data in B that has label 'Exist' is part of column A
Now I want to know opposite i.e. which data from A are part of B. For that reason I use the same formula but I replace the data in columns i.e. data from B now in A and vice versa.
Then I randomly verify results.
For case 1 it looks it works fine but for second case it looks it's not accurate.
My assumption: should it work in case 2 as well ( maybe I just was not very accurate in some way ) and I should expect it to work?
Thanks
In cell C1 (assuming your data starts from 1st row) type the following =IF(A2=B2,"equal","no"), and then populate the same formula to the last row where there is still data, so that for row N, your formula in column C is =IF(AN=BN,"equal","no"). After that you will just need to count the cells with value "no" to know the differences. Sorry if I didn't get the question correctly.
Ok, assuming that the two sets of data are in columns A and B (they might be of different sizes), and the last rows of data are L and M respectively, click on D1 and type the following: =IFNA(INDEX(B$1:B$5,MATCH(A1,B$1:B$5,0),1),"Unique"). Drag down to apply this formula on D1 - DL. That's it, you have the duplicate elements. Since the duplicate elements are the same in both columns - A and B, you don't need to repeat this for column B. Note, that for all the unique elements the corresponding rows of column D have the word "Unique", so if you want the unique elements, you can just get the elements from A with the mentioned row numbers:
Just select any column's first row cell and type the following formula: =IF(D1="Unique",INDEX(A$1:A$L,ROW(D1)),"Duplicate").

Count values in groups

I have a table with student IDs separated in groups. I need a handy way to count the total number of students in each group and populate it after the last row of each group (marked with ??)
Currently I just enter =COUNT() and then manually figure out the top and bottom borders of the range for each group. Not convenient at all.
I was thinking that a possible solution could be one of the following:
A some kind of pivot table permutation. I failed on this one.
Excel Data->Outline->Subtotals functions. Again, fail. It keeps creating new rows in my table.
A universal formula that can be pasted into each ?? cell. Not the most graceful solution, but still would do.
A macro. As a last remedy if nothing else works.
The following steps will calculate the subtotals while preserving the structuring and formatting of your worksheet.
Put this formula in cell C1 and copy the formula down the column:
=IF(NOT(ISERROR(SEARCH("Total",A1))),COUNTA(INDIRECT("B"&MATCH(LEFT(A1,LEN(A1)-7),A:A,0)+1&".B"&(MATCH(A1,A:A,0)+1))),IF(B1="","",B1))
Apply a conditional format to cell C1 with the formula rule =(MOD(ROW(C1),2)=0) and blue fill to match the shading on the other rows. Copy the format down the column using Paste Special Format.
Either hide column B, or copy the values in column C to column B using Paste Special Values and hide Column C. If you decide to copy the values to column B, you won't need to set the conditional formats.
Here is what the formula does:
First, check whether the formula's row is a Total row, by searching the cell in column A of the row for the word "Total," using the SEARCH function.
If the word "Total" is found:
Determine the range in the worksheet of the student IDs for the group for that total row:
a) Identify the rows in which the words "GroupX" and "GroupX Total" are found by using the MATCH function. With that, you know that the IDs for the group are in a range that starts at, say, row x and ends at row y.
b) With the starting and ending row numbers, construct the address range in which the IDs lie, which has to be the string "B" + (row x) + "." + "B" + (row y).
c) Turn the string into a range reference that can actually used in a formula using the INDIRECT function.
Count the number of students in the group using the COUNTA function and the range, and show that as the formula's result.
If the word "Total" is not found
Check whether the cell in column B is empty
a) If it is empty, show a blank as the formula's result
b) if it is not empty, it must be a student ID, so show the ID as the formula's result.
Add a column (I usually add it to the LEFT of the existing matrix) where you enter a formula from row 2 onwards that fills the blanks in the old column A. Then the old matrix including your new column can be used in a pivot.
So Insert a column left of your matrix, this is column A now. Put a header in Cell A1, for example "Group Name1"
Enter the following formula in cell B2 and extend it to the end:
=IF(B2="",A1,B2) This way your blanks will be filled.
Now apply a pivot on this matrix and there you are.
Maybe not the nicest looking solution, but its quick and works well.
If u have table like this
Students id Name of students group ........
then u can use countif/countifs formula

Resources