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.
Related
Compare a date on cell vs current date, lets say on A1 and B1 having a date format DD/MM/YYYY and comparing it for today's date,
If the date on A1 is less than or equal to date today and is less than or equal to the date on B1 then it will call a sub.
The only thing I do care about is how to compare those on cell and the current date.
For example I made the cell look like this
C1 cell, has value 2021 then A1 has a formula or format I made look like this: ="2/21/"&C1 (this also includes with B1) (just for flexibility of years to come).
I'm using this formula to sum some data according to 4 criteria:
=SUMPRODUCT((Data!$A$2:$A$518=Sheet2!A2)*(Data!$D$2:$D$518=Sheet2!$E$1)*(Data!$E$1:$AW$1>=C2)*(Data!$E$1:$AW$1<=D2)*Data!$E$2:$AW$518).
The formula is set up so that the third and fourth criteria are used to identify a date range that is established in cells c2 and d2 of "Sheet 2".
When I evaluate the formula I notice it is not evaluating the date ranges as I would expect. Excel is assigning "TRUE" values to all the dates when executing the (Data!$E$1:$AW$1>=C2) segment and "FALSE" values to all dates when executing the (Data!$E$1:$AW$1<=D2) segment. There are dates in the data ranging from 2017 to 2020 and the current range I'm working with is December 2018 to November 2019, so the range is within the data.
This causing the formula to return 0 as the value.
The other sections of the formula appear to be working as expected.
I've checked my formatting and all relevant cells are formatted as dates.
Are there any other suggestions?
Thank you!
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.
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
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: