Conditional formatting between values? Do I need to restructure my spreadsheet? - excel

I would like to format all cells within the range (essentially fill them with color) of start date to end date in each row.
For example, in the picture below, you can see that cells B8 and C8 contain start and end dates, 1/1/2013 and 3/24/2013 respectively. It is formatting correctly, coloring in cells D8:08.
The header cells contain dates formatted as text. For example, cell D3 (the first J), is actually the date 1 January 2013. Similarly, cell E3 (the second J), is actually the date 8 January 2013, cell F3 is 15 January 2013, and cell G3 is January 22 2013. The pattern repeats for each month, only listing the 1st, 8th, 15th, and 22nd of each month.
PROBLEM: I believe I've got it working most of the way, but it seems to not format correctly if the dates fall outside of the dates assigned in the header cells.
For example, if I assign a start and finish date of 5/31/2013, no cells are highlighted. See below image.
I assume that's because I only have up to May 22 2013 in my header cells, but I would like to keep it to four weeks in each month.
Below is the formula I used to format, which I then applied to the whole range D8:AY43, which is essentially the whole task hierarchy.
=(D$3>=$B8)*(D$3<=$C8)
Is there anyway to change this formula to accommodate my issue (cells won't highlight if they fall outside the range of values designated in the month column headers?) Or do I have to restructure my spreadsheet?
Thanks!

An alternative while keeping "4 weeks" per month would be to change the dates in header column to reflect the end of a "week", rather than the start. So instead of January 1, January 8, January 15, etc., use January 5, January 12, January 19, & January 31. You'll need to tweak your formula to account for that change, but it would preserve the structure of your workbook.
Not 100% certain what you're doing (looks like a Gantt chart?) but looks like you're just trying to evaluate whether the date in Column D is between the start and end dates in cols B & C, in which case:
=AND($B8<=D$3,$C8>=D$3)*1
This tests whether the date in D3 falls between the start/end dates defined in columns B & C, and returns "1" if true, and "0" if false.
To put this in conditional formatting, do the rule like:
=AND($B8<=D$3,$C8>=D$3)*1=1
Here is what the rule should look like in the Conditional formatting dialog:

Related

Reverse array list dynamically

I have an array list in column A (starting in A2) using:
{=IFERROR(INDEX(MonthSpend,MATCH(0,COUNTIF($A$1,A1,MonthSpend),0)),""}`
Where MonthSpend is a named range from a table on a separate sheet.
I have copied the formula down to A300, but inserted blanks in a number of rows.
From the picture you will see that I have each month showing up only on every 6th row. The formula in A8 is:
{=IFERROR(INDEX(MonthSpend,MATCH(0,COUNTIF($A$1:A2,MonthSpend),0)),"")}
and in A3:A7 there is nothing).
I named this range in column A MonthAcc.
In column B (starting in B2), I tried using:
=IF(MonthAcc>10,INDEX(MonthAcc,COUNTA(MonthAcc)+ROW(MonthAcc)-ROW(),1),"")
to reverse this list.
This didn't work because the reversal function in B2 references a row near the bottom of the MonthAcc list, which is blank.
I'm trying to get it so that in B2 (in the picture below) it would have January 1, 2020 and then in B8 it would have December 1, 2019 and then in B14 it would have November 1, 2019 and so on.
The list MonthSpend is dynamic so can be totally different lengths.
How do I reverse my dates but keep it starting at the top and only every 6th row?
In the second picture you will see a column called Month. It uses the function =IF(E3="","",DATE(YEAR(C3),MONTH(C3),1)) starting in F3 and copied down the entire table. This is the named range MonthSpend. It is dynamic in that for a different project, you could have dates ranging from April 2017 to January 2020 etc. So the months that show up in the Month column, are what I want in my new reversed list, spaced 6 rows apart.
With the column Week ending you can use the following formula:
=IF((MOD(ROW()+4,6)=0),LOOKUP(2,1/(COUNTIF(C$1:$C1,$A$2:$A$25-DAY($A$2:$A$25)+1)=0),$A$2:$A$25-DAY($A$2:$A$25)+1),"")
It returns distinct dates from list converted to first day of month (you can also convert to other formats using the appropriate functions.) in reverse order every sixth row. Dates must be sorted in source column in ascending order. BUT! For empty cells it returns first day of XX century, so I enter that date manually to C2, if it bothers, it can be hidden

Conditional Formating with if then statement

I have a workbook with 2 sheets, Sheet 1 has Column I. Column I is filled with Percent's. I want these %'s formatted as black or red based on conditional formatting.
Sheet 2 has cell B2 filled in with one of the following "Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec."
The conditional Formatting formula I thought would be something along with lines of:
If(Sheet2 cell B2 = "Feb" then If the % in Sheet 1 Column I11-I31 the column is less than 10 divided by 12, color Red.
Then the same formula for each month but 9/12 for March and so on.
Hopefully this makes sense. I appreciate everyone taking a look.
Thank you,
Matt
The conditional formulas essentially already follows the IF logic, they are expecting a TRUE / FALSE response:
AND(Sheet2!$B$2="Feb,$I11<(10/12))
The conditional formatting will automatically increment the cell references based on the absolute referencing
The IF Statement is null and void but if it helps you to understand, you would use it like so:
IF(AND(Sheet2!$B$2="Feb,$I11<(10/12)),TRUE,FALSE)
This will then return the TRUE / FALSE that the conditional formatting is expecting

Formula with IF AND applied to dates

I need column C to return today's date, only if column A and B both have a date in them. So if only one of the columns has a date in it then column C needs to remain blank. Column A already has an IF formula in it to populate it with today's date if another criterion is met.
Checking if a value is a date can be a bit troublesome - Excel will treat the number 1 as 1st January 1900 and will return TRUE if you ask if it's a date.
I found this formula which seems to work fairly well in identify a date:
=OR(CELL("format",A1)={"D1","D2","D3","D4","D5"})
http://www.mrexcel.com/forum/excel-questions/36619-there-%22isdate%22-type-function-excel.html
But, if your cell's formatted as a date but left blank it will still return true.
So, you need to check it's formatted as a date and contains a valid date.
=IF(AND(CELL("format",$A1)="D1",CELL("format",$B1)="D1",$A1>0,$B1>0),TODAY(),"")
This checks that both cells are formatted as d-mmm-yy or dd-mmm-yy and contains a value greater than 0. 1st January 1900 will still be accepted as a date - you may want to change the 0 to 42005 (1st January 2015) or some other value.
If you're not formatting your dates as d-mmm-yy or dd-mmm-yy you'll want to change "D1" for D2, D3, D4 or D5 - look at the help file for the CELL formula for more info.

Excel Convert Now() to a Number to compare against another Number

I am trying to use some logic in a spreadsheet without any macros.
First I have a sinle cell that gives the date and time. I then used the custom format on that cell to just show the "h". So only hour numbers 1 through 24 appear in this cell. (e.g. at 3:20 p.m. I get 15 in the cell). (Cell # A:1)
=now()
Second, I have a separate single column with 24 rows numbered 1-24 (Cell #'s B1:B24)
I have a third column that has logic that states "Night" shift" for numbers 23 & 0-6; "Day Shift" for numbers 7-14; and "Mid Shift" for numbers 15-22) (Cell #'s C1:C24)
=if($A$1=B1,"Night Shift","")
However, the third columns all appear blank even tough one should appear. I tried changing A1 using text(A1,"#") but I get the serial number. Is there an easy way to dynamically have a value in column C show what shift based off the hour of the day in cell A1. Column D simply concatenates all 24 cells since there will only be one number ever. (Cell # D1). Thanks for any help.
You could use a LOOKUP formula to return the shift based on a time/date value in A1, e.g.
=LOOKUP(HOUR(A1),{0,7,15,23;"Night","Day","Mid","Night"})&" Shift"
Changing the format of the cell containing the date and time does nothing to the actual contents of the cell. It will still contain a value such as 43706.75 (number of days and fractions of days since 1/1/1900).
If what you want to do is determine the shift for the date/time in A1, you could use a formula like:
=IF(AND(HOUR(A1)>=7,HOUR(A1)<15),"Day Shift",IF(AND(HOUR(A1)>=15,HOUR(A1)<23),"Mid Shift","Night Shift"))
And similar logic if you need to apply different multipliers for the salary.
If you need something else, be more specific.
By doing =now() without any formatting you get the Date and the Time. Then in cell A2 do
=(A1-INT(A1))*24
Then in cell A3 do
=INT(A2)
This gives you the hour number extracted from a date format so a comparison can be made in column C against the numbers in column B. Thanks.

Tricky Conditional Formatting Involving Actual Values vs. Displayed Values

I have read other threads that are similar to what I need, but none of them are working due to my displayed date issues. Is is possible in Excel 2013 to set a conditional formatting rule to highlight cells in column C & D based on the displayed information in column B instead of actual data?
In Column B I have dates entered in as mm/dd/yy number format, but displayed as Day of the week, Month, Date, Year (example: 02/03/14 displays as Monday, January 3, 2014). I want to highlight the cells next to it based on the displayed text, not the numbers behind it.
My goal is to highlight the cells in column C-H if the dates in column B of the same row show either Saturday or Sunday. My first thought was to truncate the first three letters from each cell in column C into empty column A (showing as Thu Fri, etc) and reference that in my conditional formatting formula, but the LEFT function wants to grab the numbers and not the words from column B.
You could use Weekday function for conditional formatting:
=OR(Weekday($B1)=1,Weekday($B1)=7)
where 1 corresponds to Sunday and 7 to Saturday

Resources