Conditional Formatting with a formula, highlighting errors - excel

I have a column (I) that is a sum of total hours worked for a month. I'm trying to apply a conditional formatting rule that will highlight cells that equal 0 but aren't blank.
The formula I'm using is:
AND(I2=0,NOT(ISBLANK(I2)))
It highlights most of the 0 values (but not all of them) and it is also highlighting some non-zero values.
I don't know if will help, but this is a sample of what I'm getting:

I had a simmilar problem a few months ago. Mark Fitzgerald pointed out the right direction to me. Times in Excel are all percentages of days. Computers calculate in binary so all those decimals have to be converted to binary before the math operation and the result has to be converted back to decimal.
But decimal places are limited to 15 in Ms Excel. You can check the whole answer here.

I think your issue is the Applies to range (though I am surprised that the Total label is not then coloured blue). It seems to me the formatting is correct but offset by one row. For simplicity, I suggest selecting the entire Total column and applying:
=AND(I1=0,NOT(ISBLANK(I1)))
Or select the range to format starting in the first cell below Total (ie Row2) and apply your formula.
Taking the 'simpler' approach, if you don't want the label formatted you might give it a rule of its own, with No Format Set chosen and make sure it has priority (eg at the top of the list with Stop If True checked).
#Dimitrios has a point (but it seems also a solution) if the values are being calculated.

=AND(I2=0,NOT(ISBLANK(I2)))
Enter the conditional formatting as a formula into the first cell. Click 'Ok'. Then copy the first cell and paste special as "formatting" to the remaining cells.
This will work as you desire.

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.

How to find duplicates when value is not equal to text?

So... this is going to be a difficult explanation...
I am using a barcode scanner to enter a 20 digit number into Excel. Due to the limitations of Excel this has to be done as text, since Excel only allows up to 15 digits.
This means that my cell has a shown value of example 00257108402007839772 but the value "behind" the cell is 257108402007839000 (the last 3 digits are turned to zeros).
I have to check the values for duplicates, and the last digits are in most cases the digits that differentiate the numbers from each other. This means that when doing a conditional formatting on the cells, the most part of the numbers are flagged as duplicates.
So my question is basically - do you know of a way to search duplicates on the shown value, and not on the "real" value of the cell?
I hope this makes sense....
Here is something for you to consider:
As you can see COUNTIF() does not work on these values, but SUMPRODUCT() will when we just directly compare a range against a single cell. Below you'll see an example of conditional formatting:
Rule used on range A1:A4: =SUMPRODUCT(--($A$1:$A$4=$A1))>1

How to set the background of three cells based off of the value in one other cell, relatively?

I'm trying to make a formula that will color code three cells that are directly above/below each other. The color coding depends on the sum of three other cells that are directly above/below each other, and directly across from the cells to be colored.
This part is easy. The rule is:
Forumula: =SUM(H5:H7)>30
And it applies to:
$E$5:$E$7
However, the issue is that when I copy the cells that are being colored (E's) to three more cells below them for the next batch, the relative formula does not work as expected. It applies the formula on H6:H8 (+1) instead of H8:H10 (+3).
Is there a way to get the relativeformula to work as expected? I hope this was clear enough. I know it's hard to visual a spreadsheet, but ultimately I need the relative forumla to add +3 instead of +1 when it is copied.
Problem:
If I correctly understand, what you are trying to achieve is to have the range E5:E7 formatted strictly based upon H5:H7, then the next three-cell range - E8:E10 - based upon H8:H10 and so on. You can do this by implementing the below solution:
Solution:
Step 1: Setup Columns as Below
Step 2: Implement Conditional Formatting as Below
Explanation:
I have recreated your issue and I see your problem; it was not that obvious until I played around with changing values of different cells in Column H.
Apparently, this has to do with how Excel interprets your instructions (formula) supplied under conditional formatting. To understand this let's first focus on the behavior of cells E5, E6 and E7 as a function of values in Column H.
With the formula =SUM(H5:H7)>30 did you notice that:
E5 format depends upon =SUM(H5:H7),
E6 format depends upon =SUM(H6:H8), and
E7 format depends upon =SUM(H7:H9) and
when you copy the range E5:E7 three cells down into E8:E10, the expected behavior is:
E8 format depends upon =SUM(H8:H10),
E9 format depends upon =SUM(H9:H11), and
E10 format depends upon =SUM(H10:H12)
And this is exactly how the range E8:E10 will behave once the above solution is applied.
A partial answer to your question has to do with your relative formula - =SUM(H5:H7) - under conditional formatting. Using this formula causes $E$5 to use =SUM(H5:H7) to determine its formatting, $E$6 to use =SUM(H6:H8) to determine its formatting, and so on. This ultimately leads to issues with the conditional formatting even before you begin copying the cells down.
EDIT: (piggy-backing off #Bharat Anand's answer)
#Bharat Anand's answer appears to be the best way to accomplish this question.
#Thisisstackoverflow requested clarification (under the accepted answer) and I'm hoping my screenshot below will help.
I set my worksheet up in what I believe is the exact same manner as #Bharat Anand, and it seems that the column letters may have been off. Setting mine up like this made it work correctly.
EDIT: (clarification for future visitors)
I really liked #Bharat Anand's solution, so I wanted to explain how it works (using the images/formulas in the solution as reference):
The calculation in Column I is setup to return a number that will only appear three times, in succession, in Column I; in this way it kind of behaves like a unique identifier, allowing other formulas to reference these values for calculation purposes.
Three times is key for the original poster because they were looking for a range of three cells to be formatted based on a sum of three cells. For example, the formula in Column I can be modified to
=ROUNDDOWN((ROW()-b)/a,0)
where:
a is your desired number of cells to format/sum, and
b is equal to a - 1.
Using the formula in J5 as an example, this SUMIF formula uses I3:I7, which includes two (or b, as setup in my explanation above) rows above and two (b) rows below to decide if I5 equals any of the values found in I3:I7. It's important to include the two rows above and two rows below so that the range overlaps the same three cells to meet the requested requirements.
When I5 finds a match, the formula looks to Column H to sum those rows in H3:H7 where I3:I7 equals I5. In this example, J5, J6, and J7 will each equal 32.
Using the simple conditional formatting formula that was setup, we know that cells in Column E should be highlighted when the corresponding row in Column H is greater than 30. According to the original question, this should be done in ranges that are three (a) rows tall. We already handled for that, so all that was left was to make sure the conditional formatting spanned the data area in Column E.
I'm hoping I don't confuse and/offend anyone with this explanation, but it's how I understand it. I like the proposed solution and explaining it to myself again helps me solidify how it works.

Conditional formatting of cells that contain formulae but no values

I like to use conditional formatting to provide extra information in my spreadsheets, but I now find myself stuck.
In a spreadsheet of cargo items, I have a column (calculated; it contains a formula) for density. Previously, it just changed text colour, so empty cells didn't stand out. But now that I'm trying to really show up any anomalies with a bright background, I've found that it (or its sibling) highlights all the "empty" cells that don't have calculated values yet.
The formula I'm using is WHERE THE VALUE IS GREATER THAN 10 for the upper out-of-bounds area, and =AND($L2<3,NOT(ISBLANK($L2))) for the lower area. I've also tried using $L2>0 instead of the NOT clause.
The ideal would be changing the upper and lower density limits based on the material it's claimed to be in the description field (column B), but I'm not bothering with that until I get this working.
Is the formula I'm using right, or should I tweak it? Would I be better off just using GREATER THAN 0 and then formatting the right densities blue as =AND($L2<10, $L2>3)?
I think counter-intuitively it is the
WHERE THE VALUE IS GREATER THAN 10
formula that may be doing the damage.
You probably have a formula in column L on the lines of
IF (<cell in previous column is empty> , "" , <some calculation>)
and when the conditional formula compares the result to 10 it actually gives TRUE because a text string is considered to be greater than a number in this context.
I suggest trying two things:-
(1) Change the colour of the WHERE THE VALUE IS GREATER THAN 10 formatting rule to see if the 'empty' cells are highlighted in that colour.
(2) Instead of WHERE THE VALUE IS GREATER THAN 10, use a formula like
=AND(ISNUMBER(L2),L2>10)
this works for me.

Excel Mass Number Checking?

I have an Excel file with over 5k+ rows and numbers.
I want to check these 5k+ numbers to see whether they have any "problems" within them (not errors such as #DIV/0, etc, those have already been accounted for).
So for example...a problem would be having a space in front of a number, causing that number to not be added to the sum of all numbers, etc... not logical errors, but more input errors. iserror would not work in this case, as it isn't a logical error.
Is there a way to do this automatically? Thanks!
Suppose all your numbers are in column A, starting at A1.
You could then in B1 put in the formula =Value(A1) and drag it down.
Then, just filter column B for #VALUE - That will give you all the numbers from column A that aren't seen by Excel as numeric.
Hope this helps!
On testing, Value() does its best to convert a value to a number, ignoring initial spaces or an apostrophe. I might use =ISNUMBER() in preference.
If you highlight the cells, say A2 downwards, you can create a Conditional Formatting, New Rule, Use a Formula, and enter =ISNUMBER(A2); choose some formatting for these cells.

Resources