If cell and statement - excel

We are trying to use cell coloring in excel.
We would like that if a cell color is red it will give a numeric answer in another cell. For e.g. if cell A2 is red then in cell B2 it will be 8.
Does anyone knows how to do it without using VBA?

There is no Excel worksheet function that can evaluate the colour of another cell.
Even if you invent a function and wing the syntax, it will not work.
The Cell() function has a "color" argument, but that does not identify the color. It returns 1 if the cell is formatted in color for negative values; otherwise returns 0 (zero).
https://support.office.com/en-us/article/cell-function-51bd39a5-f338-4dbe-a33f-955d67c2b2cf?NS=EXCEL&Version=16&SysLcid=1033&UiLcid=1033&AppVer=ZXL160&HelpId=xlmain11.chm60173&ui=en-US&rs=en-US&ad=US
So, what you want to achieve cannot be done without VBA.
You may want to shift your paradigm.
Instead of manually coloring a cell, use conditional formatting. The logic that is applied to arrive at the conditional format can be re-used to produce values in other cells of the spreadsheet.

Related

Excel 2013 conditional formatting not working correctly

I have an issue with Excel 2013. The conditional formatting just will not work. I've got a VLOOKUP which pulls data from another worksheet. Then I want to use conditional formatting on that data. The conditions are =$N$3>30 to color the cell red and =$N$3<30 to color the cell green. It just stays permanently red or permanently green. I've tried every solution and possible work around I can think of and nothing works.
Does any one have any suggestions?
enter image description here
Value in your N3 (or in column N), is a text thus color is red. Add double dash (--) to your VLookup function to convert the result to number. Your formula should be =IFERROR(--VLOOKUP(A3,... (complete the formula).

Excel: which function to use for a conditional copy of a bold cell?

I have a big data set that I want to edit.
Therefore I need to copy the value of a cell of the column before the designated cell: if it is a value that is bold. If the value in the column before is not bold, than the function needs to check the value of the column before the designated cell and one row above. If this one is bold than take this value, if not, go check the value one row above, etc.
In the picture added I made a simple example of my situation now and how it needs to be.
Obviously if the dataset was as small as in the picture it would be doable by hand. But this isn't an option with a big dataset.
Below is an example of the situation now and the outcome wanted.
First choice would be to have a list of classes in a table, and use that to determine which value to copy to column B.
Second choice would be a VBA routine to identify the bold formatting
Third choice without VBA (but referring to an XLM4 macro):
Under Formulas --> Define Name
Bold Refers to: =GET.CELL(20,OFFSET(INDIRECT("RC",FALSE),0,-1))
This will return TRUE or FALSE depending on the boldness of the first letter in the cell one column to the left of where you have entered the named formula Bold
B4: =IF(A4="","",IF(Bold,A4,B3))
and fill down.
A major problem with using Bold quality to detect is that it will not update if the Bold quality is changed unless a calculation event is also triggered. And changing the font will not do that.
That is why a list of Classes might be a better approach.
Assume you have a named range someplace called Classes
Then you could use this formula:
B4: =IF(COUNTIF(Classes,A4),A4,B3)
As you can see, they both work statically, but note that in formatting the cells, the Bold quality disappeared. Since that formula had been entered before the formatting was applied, nothing changed. So the "Table" column returns the correct result; the "Bold" column is also returning the desired result, but will not after the next calculation event.

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.

Excel Formula If Cell Contains String

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.

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