How to do conditional formatting regarding dates in excel - excel

I have a table:
I want cells which top cell (B1, C1) is older than corresponding date value (column D) to be filled with red, as shown below:
Here C3 needn't be red because 15 Feb is in February.
How can I do this with conditional formatting?

Use Conditional Formatting, Use a formula to determine... and enter the formula
=DATE(YEAR($D2),MONTH($D2),1)>DATE(YEAR(B$1),MONTH(B$1),1)
(or the shorter =EOMONTH(B$1,0)<EOMONTH($D2,0) as suggested by pnuts),
and Applies to
=$B$2:$C$4
The formula gets rid of the day in each of the two cells to be compared, keeping only the months/years. It also uses suitable relative/absolute indexing for the matrix.
I have used both, each with different formatting, to test them at once.

Use Conditional Formatting.
Use a formula to determine.
Enter the formula
=DATE(YEAR($D2),MONTH($D2),1)>DATE(YEAR(B$1),MONTH(B$1),1)

Related

Conditional Formatting with 2 formulas

I'm trying to conditional format a cell.
I have an amount in C3 (32,123.45). I have a total formula in column K (column K is totaling C9, E9, I9, J9 etc). There is a formula that is C3-K9-K13-K17-K23. The result should be $51, 123.45. Since the formatting is Accounting, it is showing ($17,123.45) instead of the $51,123.45.
I would like to use the conditional formatting so that if the result of the range (C3-K9-K13-K17-K23) is higher than C3, then it should format red. I'm having trouble with this as I'm not that good with excel. This seems to be an easy fix. Just can't find it.
With C3 Selected go to Conditional Formatting > New rule > Use a formula to determine which cells to format and enter this formula.
=SUM($C$3,$K$9,$K$13,$K$17,$K$23)>$C$3
Click "format..." and pick how you want the cell to look when it is higher than the range.
As an aside, your formatting won't change your value. Your calculation is $68,246.90 too low.

Excel - Shading entire Column based on one value

i am trying to make a work calendar for myself. screenshot of the excel file
I have written a conditional formatting to color all saturdays and sundays with the following code
=OR(WEEKDAY(B2)=2,WEEKDAY(B2)=1)
how can i make the Entire column under that day be colored.
Thanks :)
If you are not going to be moving columns around (Friday will always be in whichever cell it is at present and days just continue in sequence to the right) it might be easier to select the entire range to be subject to formatting and HOME > Styles - Conditional Formatting, New Rule..., Use a formula to determine which cells to format and Format values where this formula is true::
=OR(MOD(COLUMN(),7)=3,MOD(COLUMN(),7)=4)
Format..., select your choice of Fill, OK, OK.
Adjust 3 and 4 to match whichever day you choose to start the sequence with wherever your selected range starts.
Given information you have withheld of what is where the above might be simplified.
In Conditional formatting | Use a formula...
=WEEKDAY(B$2,16)<3
extended from B2 down and across.
Looks like you need to add a relative cell reference on B2:
=OR(WEEKDAY(B$2)=2,WEEKDAY(B$2)=1)
Here's an article about using relative references in conditional formatting: https://www.ablebits.com/office-addins-blog/2014/08/07/relative-absolute-cell-references-excel-conditional-formatting/

Conditional Formatting with Formula using Relative References

I looked around for an answer to this and found a similar thread, but it did not quite answer my question so here goes.
I have two columns, each with 262,000 rows of data. I am trying to highlight data in one of the columns based off of two conditions. I think I have the formula right for the conditional formatting, but the problem is that it will not apply to the entire column as I want it to. For example:
=AND(K6<=1638, L6=0)
That's the formula I have. I want that formatting to copy and paste all the way down column K, iterating each time. For example, the cell below should have formatting that says the following: =AND(K7=1638, L7=0) but I cannot get it to this. It just keeps looking at the values in cells K6 and L6.
Is format painter not the way to get this formatting applied to each cell?
Have you tried using conditional formatting as below?
I simplified the formula in the example but should work for your case as well.
It seems to me more practical for large ranges than Format Painter.
The formula =A2 > 4 has the cell A2 hardcoded, yet it magically works when applied to cells A6, A7, etc.. Excel uses this formula in relation to the first cell in the range, so if you wanted to highlight cells in column A that are greater than column B, and your range started in A2, your formula would be = A2 > B2.
I suggest select Column K and HOME > Styles - Conditional Formatting, New Rule..., Use a formula to determine which cells to format and Format values where this formula is true::
=AND(K1<=1638,L1=0)
Format..., select choice of formatting OK, OK.
When the rule is shown in the Conditional Formatting Rules Manager it is as applicable to the top left hand cell of the Applies to range. CF in effect raters through the range adjusting cell references automatically just as they adapt elsewhere (ie when going down Column K, K1 scrolls forward to K2 etc, whereas K$1 would stay as K$1).
You can do the conditional formatting you need by utilising OFFSET() and ROW() functions, so that your
=AND(K6<=1638, L6=0)
becomes something like:
=AND(OFFSET(K6,ROW()-6,0)<=1638, OFFSET(L6,ROW()-6,0)=0)
replace -6 with the row offset value you need.
So, for example, if you enter this formula into some cell in row 6, it will look into K6 and L6 respectively because ROW()-6 evaluates to 0 – so no offset is applied.
Then in row 7 the SAME formula will look into K7 and L7 because ROW()-6 evaluates to 1 which means offset one row below K6 and L6.

Conditional format formula using =today() and greater than / less than

Trying to set up a bit of a to do list with conditional formatting dates. Any time I open the file B2 will load =today()'s date. What I'm hoping to do is find a formula that will allow something like if C2 < B2 (Over due) then conditional formatting rule, or if C2 is 7 days more than B2 then format rule 2.
Not sure how to proceed with this as =today() isn't being treated like numeric data.
Any suggestions?
Thanks!
To apply to C2, select it and HOME > Styles - Conditional Formatting, New Rule..., Use a formula to determine which cells to format and Format values where this formula is true::
=C2<B2
Format..., select choice of formatting, OK, OK.
Then repeat with:
=C2=B2+7
and (presumably) a different choice of formatting, though could be the same (in which case a single rule would be sufficient).
Beware if C2 contains time as well as date the second rule above will not work (and not that formatting will only work for 7 days time, not 6 nor 8 ahead etc, only seventh day from today not counting today).
TODAY() could be part of the formulae (if adjusted) - does not need to bein a separate cell.
To apply to ore than one cell (eg an entire column) is quite possible with slight adjustments.

IF/AND between two dates Conditional Formatting

I am trying to implement the following logic but my formulas are not encompassing all possibilities.
Am I able to accomplish the following using the approach outlined below?
C5 has a start date(yy/mm/dd), 2013-10-01.
D5 has an end date(yy/mm/dd),2013-10-23.
F3->CX2 has 7 cells merged with the monday's date in the cell.
Example: F3: 30-Sep-13, M3: 07-Oct-13, T3: 14-Oct-13.
F4->CX4 and below are the unmerged seven cells, therefore you have seven cells below each week cell.
My goal is to use Conditional Formatting when cell has value TRUE to fill the background colour of each individual cell between the start and the end date. However I am having trouble determining the correct formula. I have tried the following in F4 and across and below but none have proven to work for all scenario's:
F4=AND(C5=F3, D5>=F3) F5=AND(C5=(F3+1), D5>=(F3+1))...
only fills the cell for the start date not all the cells between the start and end date.
In short, I need to identify the start cell and fill it, continue filling all cells until the end date.
Should this be a macro with a while loop?
***I Believe I have solved my question with the following formula:
=IF(AND((F3)>=$C$5,(F3)<=$D$5),TRUE,FALSE), =IF(AND((F3+1)>=$C$5,(F3+1)<=$D$5),TRUE,FALSE), =IF(AND((F3+2)>=$C$5,(F3+2)<=$D$5),TRUE,FALSE)...Then after 7 cells it becomes: =IF(AND((M3+1)>=$C$5,(M3+1)<=$D$5),TRUE,FALSE), =IF(AND((M3+1)>=$C$5,(M3+1)<=$D$5),TRUE,FALSE)
Should this be a macro with a while loop?
It seems it does not have to be, though that depends upon my interpretation of your question, which seems odd if only because the conditions are not in the rows for which they trigger the formatting.
Select the applicable range starting in F4 and HOME > Styles - Conditional Formatting, New Rule..., Use a formula to determine which cells to format and Format values where this formula is true::
=AND($F$3+COLUMN()-6>=$C5,$F$3+COLUMN()-6<=$D5)
Format..., select choice of formatting, OK, OK.
Here's a stepwise view on the problem as I see it:
Set up your data and include the actual date of your "weekly view" as part of the sheet:
Add conditional formatting to a single cell (say, Monday of Week 1) that applies to "a formula to determine which cells to format":
Copy-and-Paste-formats to the remainder of the cells:
The result should resemble:
Change the actual cell formatting to "" to remove the date from view:
The removes the capability to insert any content in the cells (but that wasn't part of the question). If you want to insert content and maintain colouring, you can base the conditional formatting on a similar-sized/shaped layout elsewhere in the sheet and format it accordingly. For example, the following layout provides this yet allows you to enter content in the conditionally formatted area:
Use the formula conditions. I put a start date in A1, and an end date in A2. Modify as needed per your requirements.
Then I will apply conditional formatting to values in range E1:E6. Again, modify as per your requirements.
Then simply use Highlight cells Rules > Between
Then, select your start/end values and press OK. Voila!

Resources