Nested conditional formatting for self referencing cells - excel

I am formatting an excel sheet and want to apply a conditional format to a range of cells for when the particular cell matches the one either above or below it, AND when the corresponding cell in the adjacent column matches the cell either above or below it.
an example of the information in the columns:
Name Ref ID
PER 002-003
PPJ 021-006
PPJ 021-006
PPJ 021-006
RAD 005-013
REI 006-009
RIT 005-085
STJ 002-003
STJ 002-003
TEL 002-013
TEL 007-014
So in this section of the sheet PPJ & STJ should Highlight/fill but TEL should not since while the name matches the REF ID doesn't.
I have tried:
=AND(
OR(
INDIRECT(ADDRESS(ROW(), COLUMN())) = INDIRECT(ADDRESS(ROW(), COLUMN(),-1,0)),
INDIRECT(ADDRESS(ROW(), COLUMN())) = INDIRECT(ADDRESS(ROW(), COLUMN(),+1,0))
),
OR(
INDIRECT(ADDRESS(ROW(), COLUMN(),0,+1)) = INDIRECT(ADDRESS(ROW(), COLUMN(),-1,+1)),
INDIRECT(ADDRESS(ROW(), COLUMN(),0,+1)) = INDIRECT(ADDRESS(ROW(), COLUMN(),+1,+1))
)
)
but get no response from the cells regarding the formatting changes. I have tried substituting offset for the second OR statement referring to the adjacent column but get an error about too many arguments.
Am I taking an incorrect approach to this or am I missing a step?

You shouldn't need that level of complexity. For conditional formatting you can just apply the formula that applies to the top left cell of the range, so if your data is in D3:E14 for example then you only need to use the formula that applies to D3.....so follow these steps
Select the range to format (D3:E14 in my example)
Apply conditional formatting with the formula that applies to the top left cell of the range, i.e. for your problem
=AND(OR($D3=$D2,$D3=$D4),OR($E3=$E2,$E3=$E4))
Choose required format > OK > all done
Excel will implicitly adjust the conditional formatting formula for the whole "applies to" range as if you were dragging that formula on the worksheet, so it will work as required for the whole range
Given your sample data above here's the screenshot of that CF formula applied to your data:

Related

Conditional formatting on a spilled range

(* This might be a duplicated question, but it would be surprising if we don't have this feature yet. *)
I have a table Table5 in Column C, whose height may change. in Column E, I have a formula to e.g., extract unique values, thus the resulting spilled range has a dynamic height.
I would like to make a conditional formatting over the resulting spilled range, for instance, highlight the value which is greater than 5.
But I didn't find how to define a conditional formatting rule over a spilled range (e.g., by using #). I don't want to apply the conditional formatting rule over the whole column.
Does anyone know how to achieve this?
The only way I could think of was:
=AND(ROW($E1)>=4,ROW($E1)<=COUNTA(UNIQUE(INDIRECT("Table5[Coefficient]")))+4,$E1>5)
Use the above formula as a conditional formatting rule on the whole of column E:E.
You could set a conditional formatting rule over the whole column, but use some additional logic to ensure it only applies to the range you want, ie:
=AND(ROW(E1)>=4, ROW(E1)<=4+COUNT(UNIQUE(INDIRECT("Table5[Coefficient]"))), [your condition here])
Apply the rule to E:E and it will only evaluate to True for rows in the range you want.
Update
The Indirect reference can use the spill range, so you could use:
=AND(ROW(E1)>=4, ROW(E1)<=4+COUNT(INDIRECT("E4#")), [your condition here])
Note that Unique is no longer needed. Also, this assumes the values in your table are only numbers.
An alternate workaround is to use a named range which will accept the spill range # assignation.
Assign Named Range "CF_1" as:
=OFFSET($E$4,0,0,COUNTA($E$4#))
The conditional formatting to be applied to E:E can then be:
=AND(ROW(E1)=MEDIAN(ROW(E1),MIN(ROW(CF_1)),MAX(ROW(CF_1))),E1>5)
In essence, this isn't too much different to the answers by JvdV and Professor Pantsless as it kind of boils down to the same thing, but it does have the bonus that it will only apply to only the rows of the spill range (the cells E1-E3 haven't been taken into account yet for the other answers to date).
UPDATE
And in fact, you don't have to use a named range at all as this code will also accept # (still can't work out how to apply over only the spill range though)
=AND(ROW(E1)=MEDIAN(ROW(E1),MIN(ROW(E$4#)),MAX(ROW(E$4#))),E1>5)
I've been using several different conditional formats applied to the entire column, or group of columns. The table looks like this:
The following formulas are conditional formatting applied to the entire row/rows, not individual cells:
Header:
=AND(OR(ISERR(OFFSET(A1,-1,0)),ISBLANK(OFFSET(A1,-1,0)))=TRUE,ISBLANK(A1)=FALSE)
Band:
=AND(CELL("row",A1)=EVEN(CELL("row",A1)),ISBLANK(A1)=FALSE)
Last row (or total row):
=AND(ISBLANK(A1)=FALSE,ISBLANK(A2)=TRUE)
With the following formatting:
If you do not want this formatting to be applied to non-spill cells, you can determine if a cell was spilled or directly input. You can do this with a formula or write a UDF.
Using a formula you need to fake it. You can use ISFORMULA to find where the spill formula was entered, and NOT(ISBLANK()) to identify spilled rows. You would then have to assume a formula followed by non-blank, non-formula cells is a spilled formula. Helper columns may be helpful.
Using a UDF, you can directly determine if a cell is spilled. Below is a basic example. You can add more checking to determine if the formula is actually spilled if desired.
Public Function isFormulaOrSpill(ByVal rRange As Range) As Boolean
Dim this_bIsSpill As Boolean
Dim this_bIsFormula As Boolean
this_bIsSpill = rRange.HasSpill
this_bIsFormula = rRange.HasFormula
isFormulaOrSpill = (this_bIsSpill Or this_bIsFormula)
End Function
Recently I've been building entire tables as spilled ranges (including header and total rows). Here is an example of those who want to give it a shot:
=LET(
Column_Key, Table_Status[System],
Column_FtEstimated, Table_Status[Estimated],
Column_FtModeled, IF(Table_Status[Modeled]>Table_Status[Estimated],Table_Status[Estimated],Table_Status[Modeled]),
Categories, SORT(UNIQUE(Column_Key)),
Array_BoolKey, (TRANSPOSE(Column_Key)=Categories)+0,
Mask1, TRANSPOSE(ISNUMBER(XMATCH(Column_Filter1,List_Filter1))),
Mask2, TRANSPOSE(ISNUMBER(XMATCH(Column_Filter2,List_Filter2))),
Array_BoolMasked, Array_BoolKey,
Masked_FtModeled, IFERROR(Array_BoolMasked*TRANSPOSE(Column_FtModeled),0),
Masked_FtEstimated, IFERROR(Array_BoolMasked*TRANSPOSE(Column_FtEstimated),0),
Array_Ones, SEQUENCE(COLUMNS(Array_BoolMasked),1,1,0),
Body_Count_Lines, MMULT(Array_BoolKey, Array_Ones),
Body_Sum_FtModeled, MMULT(Masked_FtModeled, Array_Ones),
Body_Sum_FtEstimated, MMULT(Masked_FtEstimated, Array_Ones),
Body_Percent_FtModeled, IFERROR(Body_Sum_FtModeled/Body_Sum_FtEstimated,"-"),
Total_Count_Lines, IFERROR(SUM(Body_Count_Lines),"-"),
Total_Sum_FtModeled, IFERROR(SUM(Body_Sum_FtModeled),"-"),
Total_Sum_FtEstimated, IFERROR(SUM(Body_Sum_FtEstimated),"-"),
Total_Percent_FtModeled, IFERROR(Total_Sum_FtModeled/Total_Sum_FtEstimated,"-"),
Array_Seq, {1,2,3,4,5},
Array_Header, CHOOSE( Array_Seq, "System", "Lines", "Modeled Feet", "Estimated Feet", "Percent Modeled"),
Array_Body, CHOOSE( Array_Seq, Categories, Body_Count_Lines, Body_Sum_FtModeled, Body_Sum_FtEstimated, Body_Percent_FtModeled),
Array_Total, CHOOSE( Array_Seq, "Total", Total_Count_Lines, Total_Sum_FtModeled, Total_Sum_FtEstimated, Total_Percent_FtModeled),
Range1,Array_Header,
Range2,Array_Body,
Range3,Array_Total,
Rows1,ROWS(Range1), Rows2,ROWS(Range2), Rows3,ROWS(Range3), Cols1,COLUMNS(Range1),
RowIndex, SEQUENCE(Rows1 + Rows2 + Rows3), ColIndex,SEQUENCE(1, Cols1),
RangeTable,IF(
RowIndex<=Rows1,
INDEX(Range1,RowIndex,ColIndex),
IF(RowIndex<=Rows1+Rows2,
INDEX(Range2,RowIndex-Rows1,ColIndex),
INDEX(Range3,RowIndex-Rows1-Rows2,ColIndex)
)),
Return, RangeTable,
Return
)

Excel: Use Cell Range which is saved in a cell for completing a formula in another cell

In the above Table i would like to use the range defined in V2 for the formula defined in E2. It should replace the green underlined part of the formula. As you can see there is already the right range in there but it is for flexibility reasons if the range changes so i don't have to change all the formulas which are in E2,F2,G2,... and so on.
The Formula:
=VLOOKUP("contract index",INDIRECT("'PURCHASING'!"&V2),2,FALSE)
Try,
=vlookup("contract index", indirect("'purchasing'!" & v2), 2, false)

conditional formatting of a cell when a cell name is used on a formula inside that cell

I am trying to apply conditional formatting to a cell when it contains an equation with reference to a named cell.
Example: Cell I71 contains the following equation. =G71*Admin_Labor_Rate
Admin_Labor_Rate has a value of $50, and is the name of cell B152.
Now I want to find all cells that reference cell B152 "Admin_Labor_Rate" and apply conditional formatting (highlight). I have two other Labor Rates, so I want to use cell highlighting to distinctly identify if the labor is being performed by technicians, admin, or engineering.
I have done a lot of research and tried a lot of methods, but it seems as close as I can get is if the cell equates to a certain value, then I can format it.
Thanks in advance for any thoughts the community may have on this.
Use this formula with conditional formatting:
=ISNUMBER(SEARCH("Admin_Labor_Rate", FORMULATEXT(A1)))
Where A1 is the top-left cell of the range you want to conditionally format. For example, you select range F20:H30 and enter the formula with F20 instead of A1.
Perhaps a User Defined Function (i.e. UDF).
function formulaContains(rng as range, nr as string) as boolean
formulaContains= rng.hasformula and cbool(instr(1, rng.formula, nr, vbtextcompare))
end function

Using IF Function Range in Excel

I have some problem in using If Excel function. I want to use range in excel. So when my data is in range, it will show something. I use this formula but it doesn't work "
=IF(E11=Rekap.C8:C21, VLOOKUP(Rekap.C8:C21, Master.A2:C148, 3), "")
Form that formula, if data in E11 is same like data in range C8 - C21 in Rekap sheet, it will show another data in Master sheet that in range A2-C148 column 3. How can I use range in if formula ?
A single cell like E11 cannot be compared to a range like C8:C21.
I assume that you really want to check if the value in E11 appears anywhere in the range C8:C21 and if so, perform the lookup. That can be done in several ways
=if(isnumber(match(e11,Rekap!$C$8:$C$21,0)),vlookup(E11,Master!$A$2:$C$148,false),"")
Note that I added the fourth parameter to the Vlookup. It will default to TRUE if omitted, which may return wrong results if the lookup table is not sorted.

applying formatting for cell based on result(true or false) in EXCEL

I am trying to format cells based on values entered in cell. The cells represent multiplication sheet. After entering data B2 cell, if result is multiple of its row and column I.e 2 x 2 = 4 it should be green , otherwise it should be red . In short, I want to make this a multiplication trainer sheet. I tried using an if condition, but couldn't figure out how to put color for true and false.
The conditional formatting works fine when each cell of dest sheet dest sheet to test multiplication skills is referred whith source sheet from which tables can be learned referred with each cell of source sheet . When I tried to specify ranges in condition of formatting it throws an error and it says only map one cell instead of range. Its rather hard to map each and every cell to compare result . Please help me to format to differentiate true and false after entering value into cell.
you can download my file from here . http://s000.tinyupload.com/?file_id=00186543650788471896
Select the range you would like to format, enter conditional formatting:

Resources