Cell reference in conditional formatting - excel

My apologies if all the text in this document is in German, I'll try to explain it as well as possible.
Basically, this is just a sheet that contains the dates and times an employee was working. All the weekdays are automatically generated, e.g. when the month is set to October 2013, the weekdays automatically update. ("Di" -> "Tu"/tuesday, "Mi" -> "We"/wednesday, ...)
This works out alright, so I don't have any problems with that. What the actual goal is, I wanted to make it a little bit better readable by adding thicker lines after every sunday, signalizing the end of the week.
Using the conditional formatting, I've managed to do that for every line. E.g. for line 14, I used the formula =MOD(VALUE($B$14);7)=1 to determine, if the value in column B and line 14 is in fact a sunday. If the modulus of the weekday divided by 7 is 1, then it is a sunday and the formatting style is applied to those cells.
Now, this formula makes it a little hard to work with. I'd basically have to copy-paste the lines each time and change the line number for each line. I thought it would be possible to make it more dynamic by leaving out the $-symbol (=MOD(VALUE($B1);7)=1), but for some reason it didn't work for me.
What do I have to type in inside VALUE to reference the B-Column in the same line?

Okay, the issue was that you were applying your condition on a range on the wrong active cell.
An active cell is the only cell which is slightly less blue in the selected region; for instance, in the picture below, the active cell is A1:
And if this is the active cell, you will be able to use your formula:
=MOD(VALUE($B1);7)=1
There's a simpler formula though:
=WEEKDAY($B1)=1
This means that if the active cell was A32 or H32 in the picture, the formula wouldn't have worked, because the condition for formatting is being applied to the wrong cell!

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.

Increment numbers starting from Zero in any cell without specific reference in Excel

I want to increment numbers starting from Zero in any cell without specific reference in Excel without VBA. I know to use col()-col($A$1), or a helper column, a1+1, auto-fill options. They all require a reference cell which much be changed if the starting cell is changed. but I have many offset formulae which reference the same ranges but from different cells.
Essentially what I've been unsuccessfully trying to do is have the one formula to paste into any cell, named range or other formula to increment by 1 starting from zero in any cell.
I don't think it should be hard to to, but so far my search has not yielded desired results as per my requirements.(As a last resort - after looking through all the aisles 4 times in every supermarket, twice) I'm asking the question.
What I want is:
0
1
2
3
4...etc. with rows or columns. in any cell without having to reference a absolute cell because I'll have to keep changing that reference with every formula in a different cell.
OFFSET(payments!$E$14,,GCD((COLUMN()-COLUMN('error test'!$B$1))*5),COUNTA(OFFSET(payments!$E$14:$E$522,,GCD((COLUMN()-COLUMN('error test'!$B$1))*5))),1)
(COLUMN()-COLUMN('error test'!$B$1) - this part is just to start at 0 but I have to keep changing the reference $B$1 whenever i put the formula into a different cell or table or pull data from another range. I have many like this, each one has to be carefully examine and changed accordingly to make sure the reference is correct.
Once I added an extra column to my data table, I had to go through every cell and every formula, name ranges, conditional formatting, and change the reference.
Surely there must be a way without using VBA to start counting from zero without needing to manually change a reference every time it moves.
I've tried variations of sum(row()-1+row()), mod, gcd. could there be a way to have an absolute reference move with a cell?
I've just figured it out! i can't believe the answer eluded me for so long!
columns($A$1:a1)-1
This will give me a result of zero, and increments when filled across.
0 1 2 3 ...
rows($A$1:a1)-1 will do the same for rows.
I know it references a cell, but this way it doesn't matter which cell this formula is placed into, the result will always be the same. However if you insert of delete cells, just refill the formula through the desired cells.
I think this will be much easier than column()-column($A$1).
Thanks guys for your help.

Conditional formatting highlighted a Date Range

I’ve been struggling to try and figure this one out, it to do with conditional formation in Excel. I want to find a way to highlight the next payment schedule based on the current date. So if today was 10 Feb, the next payment schedule would be 15th Feb and is therefore highlighted. If today was the 16th Feb, A6 and B6 would be highlighted
Can any one help me with the formula for this, I’m assuming its conditional formatting with a formula. but the formula stumps me. this formula would need to be applied to a large range of dates (600 dates)
Simply try this formula:
=COUNTIFS($A$2:$A$9,"<="&$A2,$A$2:$A$9,">"&TODAY())=1
if you want to show also a day which is the actual day then simply add the = to the today part:
=COUNTIFS($A$2:$A$9,"<="&$A2,$A$2:$A$9,">="&TODAY())=1
but make sure to not miss any $ (or do to much of them) ;)
alternatively you also could use the short formula (which may be slower for bigger tables:
=$A2=MIN(IF($A$2:$A$9>TODAY(),$A$2:$A$9))
$A$2:$A$9>=TODAY() will include the actual day

Conditional Formatting rows with shared Merged Cell

I've got a little helper spreadsheet that I use, and there are some Merged Cells.
Rather than get rid of these, which I know can cause headaches, I was looking for an idea on fixing an issue.
I have a few rows that share a merged cell. When this merged cell is not empty, I want the rows to highlight. Currently, the formula (applied over A1:B4) is =$B1<>"" and then a fill. Works okay for the first row, but not the other three:
I was thinking I could add some more logic, but there's nothing really there for me. It's a pretty simple table. Unfortunately, there's not really a way to say (for rows 2:4), if row 1 is colored, then color this row...(Although I think I've seen clever uses of Named Ranges to do something like that, but I could be mistaken).
So, in A2, what's the conditional format formula "thinking"? Is it going to =$B2<>"", in which case ...what's it looking for as B2? If I select A2, and look at the conditional format rule applied to the current selection, it still shows =$B1<>"".
Thanks for any ideas/tips. It's not a huge deal, so I don't need a VBA solution - just maybe an idea or trick for using CF with merged cells.
Edit: For a more full explanation - the idea is that col. B will have an invoice number and if it's there, make the row a color. I will be repeating this "chart" a bunch, and have some non-grouped companies, who have their own lines. I just don't like the gap of color there in my group and was trying to get it to have a color when the first of the group does.
I usually try to base my CFR's on formulas.
    
After selecting all of column A and B I created a CF rule with the following.
=AND(LEN($A1), ISNUMBER(MATCH(1E+99, $B$1:$B1)))
The approximate MATCH function simply looks for the last number in the B column. I can see a missing invoice number in a cell like B7 would generate confusion but perhaps you can expand on this for conditions not demonstrated by your examples.
If you want to use "placeholder" instead of blank cells (when there is no invoice), you could try the following formula:
=(LOOKUP(2,1/($B$1:$B1<>""),$B$1:$B1)<>"x")*LEN(A1)
With sample data it looks like this:
When the cell is left blank (no placeholder), column A is highlighted, column B is not.

Conditional Formatting with a formula, highlighting errors

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.

Resources