Excel Formula If Cell Contains String - excel

I'm currently working in excel, and I'm trying to figure out a way to find if multiple cells contain the string value of another cell, and if it does highlight the cell where the row and column meet up. I created an example of what I want, only it will be on a much larger scale.
I've tried using: =ISNUMBER(SEARCH(substring,text)) but I'm not quite sure how to use it the way I want to.
Any help will be appreciated!

Your approach is correct, we can use the fact that conditional formatting is applied like dragging a formula, adapting relative references.
Create a conditional formatting formula rule:
=ISNUMBER(SEARCH(B$1,$A2))
Applied to B2:D7

Your formula will work nicely; what you'll want to do is put that formula into all the cells you want to highlight, so you get FALSE and TRUE in every cell.
You'll then use two Conditional Formatting rules. The first will look for Cell Value = TRUE, and will set cell background and font colour to yellow. The second will look for Cell Value = FALSE, and will set cell background to No Colour and Font to White.
This will reproduce the result you're looking for.
Edited to add:
It is possible to do this using just Conditional Formatting too, but it's a little more fiddly. If you want to try it, you can do this:
Highlight your range, and take note of which cell is Active - that's the cell within your highlighted range that is still white. It's also the one whose address is shown in the Name box in the upper left. For the sake of this answer, we'll assume that's B2
Create a new Conditional Formatting rule. Choose "Use a formula to determine which cells to format".
Use the formula =ISNUMBER(SEARCH(B$1,$A2). Set the format to colour just the cell background.
Note where the $ appears in the formula above - you want to leave the row number anchored in the first part, and the column letter anchored in the second part.
This takes advantage of the fact that Conditional Formatting is able to use absolute, relative, and mixed references to find which cells to format. It's also a tidier solution, but it can be harder to maintain if the sheet is ever repurposed or modified.

Related

how do I compare each row of two different columns and highlight the highest value (not formula) in each row?

I have two columns to compare. All cell values come from the ROUNDUP function. =ROUNDUP(C6/D12,0) etc.
I want the larger, or equal, of the two in each row to be green and the smaller red. Using the formula, it does not work as expected. If I do the same with numbers typed, not the formula, it works. It appears the formatting applies to the formula and not the value.
That is the first half of the problem. I also want to autofill/paint the conditional formatting to numerous cells, but it always compares to the top left cell, rather than the two cells on the same row.
If I use the color scales formatting it works, but I do not want the scales, just red/green.
It seems hard to believe that what I want to do is not possible. Can someone please help me with this. Thanks in advance.
In conditional formatting, under 'use a formula to determine which cells to format', you need to enter
=A2=MAX($A2,$B2)
to highlight the larger cell and (as a separate rule)
=A2=MIN($A2,$B2)
to highlight the smaller cell.
Note that in the case where both cells have the same value, they will both be either coloured red or green depending on the precedence of the rules. If the 'green' rule comes first,
it will look like this:
Conditional formatting is almost its own little science within Excel. It may be more useful to find youtube tutorials on the topic than depend on a text explanation here. But the central theme is this.
You will use location locking (the dollar sign or F4) in front of the letters so that any cell to which the format is applied knows you specifically mean columns E and F, for instance.
Example: Assume your first row goes from A5 to M5, and the condition values are in E5 and F5.
I find it easiest to format one row with the rules I want, test them, and then use the format painter or copy -> paste format along with careful use of $ locking.
Drag over and select the entire row of cells A5:M5
Conditional Formatting -> New Rule -> Use a formula to determine which cells to format
In the formula field enter =$E5>$F5. Excel gets weird and often inserts double quotes. If you save the rule and go back in, it may say ="$E5>$F5" and if so delete the double quotes.
Click Format and create the cell format you want.
With A5:M5 still selected, add another rule and format for ="$E5<$F5"
The $ sign works the same way as it does in a formula. All of the columns get their format based on columns E and F, but all of the rows base their formula on the E and F values in that same row.

Conditional formatting multiple rules to single cell

I have used one formula to change the font colour if a cell contains the text "complete" & another formula to add a light blue fill to the entire row if the word "odd" appears in a cell which is in a different column to the first formula.
The conditions seem to clash & although I have changed and played with the order of the conditions & checked there is no conflict in the fill/background or the font colour, even when changing the font colour manually again the fill from the second formula returns the font the cell to black although it is set to automatic in the conditional formatting rule with the fill ?
I wonder where i am going wrong as everything suggests the two conditions should work fine together though when the fill is applied the font goes back to black when it should be green ?
Have you any suggestions ?
I found the issue, I needed to press clear on the font section of the formatting on the fill condition and then clear on the fill. Basically as a rule I press clear on anything not required in that condition and this seems to avoid the conflict and run upto 6 rules on the same cell with no problems!
You can combine multiple conditional formats overlapping cells/rows. (Excel's just a little picky that you do it just right!)
Always use New Rule as opposed to using the built-in rules.
Choose Use a formula to determine which cells to format.
For your example question, I populated the cells as shown above. Select cell B4 and set the conditional formatting as above =($B4="complete") . Note that I removed a $ (dynamic vs absolute cell reference) that was automatically filled in, so that I can fill the formatting's formula down.
Highlight entire Row 4 and set the conditional formatting as below. Again, note the modified $.
When it's working properly, copy entire Row 4, select the rows to which the formatting should be applied, and Paste Formatting.
[
Obviously the steps will vary for you depending on your data and what's in the neighboring cells whose formats you may or may not want affected by the formatting and copy/pasting.
Let me know if that works for you.
From my experience with conditional formatting, I believe that it applies a format to the entire cell rather than individually modifying fill or font colour, so formats will not combine. I had a similar situation and solved it by creating an additional rule. In your case, one that applies your desired font colour and background fill to the 'complete' cell if the same row also contains 'odd' using the AND() function.

Apply Conditional Formatting to Range but Only Format Cell Where Condition Is True

I have a sheet that looks like this:
The coloured cells need to be a specific colour based on their value. I am currently using conditional formatting to achieve this, but I am only able to get it to apply to a single column instead of the entire range A:G. For example, here’s my formula for column A for values that should be coloured light blue:
=OR($A1="CA515",$A1="CA525")
And applies to:
=$A:$A
Using the above formula, if any of the cells in column A contain the value CA515 or CA525, the cell alone is coloured light blue. Is there any way to use a single conditional formatting formula to make it possible that if any of the cells in the range A:G contain the value CA515 or CA525 that only that cell alone is coloured light blue? Or do I have to apply the formula to every column individually, or possibly even resort to VBA?
Thank you in advance!
You can avoid using VBA here*... Remove the dollar signs in your conditional statement, it should be
=OR(A1="CA515", A1="CA525")
The dollar signs specify whether the reference is relative or absolute. To visualise how this works, try typing these formulas into a cell and dragging the corner of the cell down to autofill:
=A1 'Autofilling this down will give =A2, =A3, ...
=$A1 'Autofilling this down will give =$A1, =$A1, ...
So by removing $, your format condition should be spread across the range. To set the range, change "applies to" to $A:$G.
Note: many conditional formats over a large range like this could severely impact the speed of your document. Consider at least limiting the number of different formats, or the number of rows it's checking.
*Although the above method does avoid VBA, it might be quicker to write your own formatting routine in VBA, since it wouldn't have to get checked so frequently and it would be unaffected by moving around of ranges which messes with conditional formats.

Checking cell value dynamically

What I'm doing is a simple map on one tab of an office space that has all the cubicals laid out. On this map, I have conditional formatting checking another table of listen computers for the last time they were updated/maintained. It works as it stands, but we are moving into a new building and the map (which is already done) has WAY more cubes than last time. So I'm trying to figure out a more efficient way to do this task.
Here is the code:
=AND(VLOOKUP("CCA C1",LOCATION,3,FALSE)<>"",VLOOKUP("CCA C1",LOCATION,3,FALSE)<TODAY()-80)
So as it sits, it works fine. But what I'm trying to do is change the "CCA C1" to simply read the contents of the cell it's formatting so I can just format an entire range of cells rather than doing it cell by cell. The "CCA C1" is in the location of the second sheet (it's a named range). So this checks that entire range for "CCA C1" and checks if the date a couple columns over in that row is within 80 days, if it's not it highlights the cell in the map in red reminding us we need to check the computer. But what I would like to do is simply put "CCA C1" in the cell in the map (which is already is labeled), and have this check for the value of the cell it's formatting and look for that value the same way it's looking now. Just without me having to put "CCA C1" in the formula, I'd like to say something like this:
=AND(VLOOKUP(CURRENT CELL VALUE,LOCATION,3,FALSE)<>"",VLOOKUP(CURRENT CELL VALUE,LOCATION,3,FALSE)<TODAY()-80)
Make sense? Anyone know of a way to do this? Otherwise I have to conditionally format each individual cell with the value manually rather than just format all the cells with the same formatting and have the formula check the contents of the cell for what to look for in the location range of the other sheet.
And to clarify, I know that I can put in the actual cell, such as E3, but then I still have to manually change the formula for each cell which defeats the purpose. I want to just say current cell or something like that. I have 3 conditional formats for each cell, I have around 100 cells to be formatted, so rather than having 300 formats I have to put in, I'd love to just do 3. Not sure if this is possible, that's why I'm asking :)
Just replace "CCA C1" with the address of the first cell in the range of cells with the conditional formatting. Assuming your conditional formatting starts in B2:
=AND(VLOOKUP(B2,LOCATION,3,FALSE)<>"",VLOOKUP("CCA C1",LOCATION,3,FALSE)<TODAY()-80)
EDIT: As I commented, I'm not sure I understand the issue, but if I do, you need to enter the range of cells with CF in the applies to range of the CF dialog, rather than copying and using Paste Special:
Note that this works with the merged cells.
You will need to adjust the applies to range as you add more computers, etc., but the same formula will work.

Excel Conditional Formatting and dragging to neighbouring cells

I have a condition set up =IF(C2<42,C4="") the background color will turn red if met.
When dragging the crosshair (at the bottom left of the cell) to neighbouring cells, the formula stays the same.
I need the formula to then change to =IF(D2<42,D4="") and so on 300+ times, Is there any way to refer to the current column i.e =IF(thiscolumn-row2 < 42, thiscolum-row4 = "")
Excel sometimes by default puts dollar signs in front of the cell/row labels
(ie $C$4 instead of C4 .... the dollar signs tell excel not to change the formula with each row but to lock in the original values. Does your rule in conditional formatting show dollar signs? That may be your problem. Get rid of the dollar signs and what you need should work.
You don't use If in Conditional Formatting formulas. The formula itself defines the condition that you are looking for, so the if is already implied. So your formula should simply be something like:
=C2<42
I'm confused about the 2nd part of your formula, C4="". Is that supposed to be a 2nd condition? If so, use an AND statement:
=AND(C2<42,C4="")
If you are using Excel 2007 or 2010 another source of potential confusion is that references don't change in the Conditional Formatting formula box when you drag them around, even if they are relative.
Assuming you want to apply formatting to the range c1:d300, select that range of cells, bring up the conditional formatting box and enter:
=AND(C2<42,C4="")
Now it will apply the formatting with relative references to the full selected range.

Resources