I would like to use Excel validation to allow only entries which are either a date from this calendar year or next or text from a predefined list.
For example today is 12th Jan 2017.
If a date is entered (in say cell C1) then this date must be in 2017 or 2018.
If text is entered then it must match one of the entries in a predefined list.
Let's say the list in this example is named 'reasons' (these reasons would be something like 'To be confirmed' , 'beyond planning horizon' etc.)
01/12/2019 should be rejected
01/12/2018 should be accepted
'beyond this month' should be rejected
'beyond planning horizon' should be accepted
I believe I should be using custom validation but I would appreciate if anyone could help with the syntax, please.
Okay, we finally made it (for some reason the validation formula did not like my COUNTIF() being part of the OR() statement so I had to nest a TRUE result as part of a separate IF() statement:
=IF(COUNTIF(reasons,C1)=1,TRUE,OR(YEAR(C1)=YEAR(TODAY()),YEAR(C1)=YEAR(TODAY())+1))
Like you said this will be in custom validation. Be sure that the $$'s dont go in it as it will need to update the cell range down the column.
The logic is if the entry appears in the named range reasons once then TRUE otherwise do the OR year matching this year or next (returns TRUE by default if the conditions are correct).
Related
I am attempting to show the date in a cell that is between the 2 dates. Today is 2021/06/14. So in theory the cell above the first column of dates should show 2020/11/01. For some reason, it keeps showing false but when I check the formula, there are definitely 2 True values and that is "2020/11/01" and "2021/10/31". If someone can help me with this, I'd much appreciate it.
If you used the correct syntax for dates (and by 'correct' I mean consistent, i.e. either dd/mm/yyyy or mm/dd/yyyy, but not both simultaneously), you would see that your version of the equation evaluates to the following:
IF(AND({TRUE;TRUE;TRUE;FALSE;FALSE},{TRUE;TRUE;TRUE;TRUE;TRUE}),J5:J9,"n/a")
The AND statement will only evaluate to True if both sub arrays are identical (i.e. if all dates were = today).
One way to get the desired result is as follows (screenshot refers, noting the consistent use of date format in both columns...):
i.e. using the following eqn:
=INDEX(J5:J9,MATCH(1,(J5:J9<=TODAY())*(TODAY()<=K5:K9),0))
If you have Office 365, then you could return all such instances using the following, per 2nd screenshot below:
=FILTER($J$5:$J$9,(J5:J9<=TODAY())*(TODAY()<=K5:K9))
I've got a data-set, for example purposes it's a list of people (who may appear more than once) with various fields.
I need to return every match and I've done this with an array formula.
My data looks like this from Column A to F with the look up result shown in Column F. (I've simplified it for sample purposes):
and the data updates perfectly when i update the name in cell F1
This is my formula
{=IFERROR(INDEX($C$2:$C$27, SMALL(IF(COUNTIF(F$1,$A$2:$A$27), ROW($C$2:$C$27)-1,""), ROW()-1)),"")}
However I need to also to include the date in the criteria, specifically I want to be able to provide a date range, and then only return matches that are within that date range.
I've found many examples of having multiple matches in the criteria (using more than 1 countif and multiplying the results together) but nothing that will allow me to specify a date range.
I don't want to use VBA for this, hoping someone out there can assist.
always the case.
After posting that query, I managed to work it out myself.
I just changed my formula to :
{=IFERROR(INDEX($C$2:$C$27, SMALL(IF(COUNTIF(F$1,$A$2:$A$27)*($G$1>=$B$2:$B$27), ROW($C$2:$C$27)-1,""), ROW()-1)),"")}
(where G1 had a date in it) i also added a <= statement in there as well to give it a start and end date
sorry for wasting the time of anyone who looked into this for me
I'm having an trouble making an excel formula at the moment which would first search for the value by getting the year from the dates and then search another value from the sheet. Finally return the count.
Please, let me know how can I do this. I've been stuck at this a long time.
Right now i'm using this formula.
=COUNTIFS('Inc'!$F$2:$F$984,"YEAR('Incg'!$F$2:$F$984)=2017",'Incident Log'!$J$2:$J$984,$F9)`
You can't use YEAR() as an argument to COUNTIFS in this case, because its output is the numerical value 2017 whereas the value you want to use for your comparison is 42736, the internal representation of this year. A possible workaround is:
=COUNTIFS('Incident Log'!$F$2:$F$984,">="&DATE(2017,1,1),'Incident Log'!$F$2:$F$984,"<"&DATE(2018,1,1), ...)
This extracts the numerical date values of January 1 2017 and 2018, and checks whether each value lies between those dates.
If you do want to use YEAR() then you can use it with SUMPRODUCT, which was the usual way of solving problems like this before COUNTIFS became available.
=SUMPRODUCT(--(YEAR('Incident Log'!$F$2:$F$984)=2017),--('Incident Log'!$J$2:$J$984=$F9))
I want to avoid VBA as much as possible and try to find a solution in a single cell--if possible. I have been trying to find a way to do so, but I have no idea how to.
The logic is summarized in the image below. In words, the conditions are:
Search Name is looked for in the Name column of the right table.
Search Date has to be greater than the Date in the right table.
Search Date minus Date has to be the positive minimum value.
Return the Pay that matches the criteria--which is 500 in the example.
You could use the following array formula (i.e. you need to enter it with Ctrl+Shift+Enter, if you are successful, you will see the braces appear in the formula bar):
=INDEX(G:G,MATCH(A2,IF(F:F=B2,E:E)))
The formula will return #N/A if there are no dates earlier than the Search Date.
NOTE: The dates have to be sorted in ascending order for this to work
EDIT: A little more robust that doesn't require sorting:
=INDEX(G:G,MATCH(MAX(IF((F:F=B2)*(E:E<A2),E:E)-A2),IF((F:F=B2)*(E:E<A2),E:E)-A2,0))
Note: Since this doesn't use MATCH, you won't get #N/A in case there are no dates earlier than the Search Date and you will instead get Pay (i.e. the header). If you want to get something else, then you can wrap the whole function in an IFERROR, relying on the fact that excel returns an error if one attempts to multiply a text with a number, something like this:
=IFERROR(Formula*1, "No pay matched")
This can be done with SumProduct, which does not require Ctrl-Shift-Enter
=SUMPRODUCT($G$2:$G$9,(A2>$E$2:$E$9)*(MONTH(A2)=MONTH($E$2:$E$9)*($F$2:$F$9=B2)))
The logic commands that the Search Date is in the same month as the Date column.
If you have the new Dynamic Array functions, that are currently in preview in the Insider Fast build of Excel 365, you can use
=FILTER($G$2:$G$9,(A2>$E$2:$E$9)*(MONTH(A2)=MONTH($E$2:$E$9)*($F$2:$F$9=B2)))
I got an answer for a previous question regarding an IF function on my excel tracking sheet.
I would like to further this by adding another formula to the existing formula.
I am looking for some help regarding an IF function on an Excel
document.
Basically if the Date Listed cell is dated over 1 month ago (eg: Date
Listed 6-Aug but today is 6-Sep) and the Date Sold cell is blank, then
I would like the Mark Down cell to say 'MARK DOWN', which at the
moment it does but it is only 10-Aug today.
If the Date Listed cell and the Date Sold cell both contain dates I
would like the Mark Down cell to say 'OK'.
So far I have this written:
=IF(AND(DATE(YEAR(G2),MONTH(G2),DAY(G2)), ISBLANK(H2)),"MARK DOWN","OK")
I know I'm not far off but I need help sorting out the
last parts..
Bonus if you can help me add a highlighted cell formatting to it :)!
Example Image
******Original formula:
=IF(AND((TODAY()-G11)>31,ISBLANK(H11)),"Mark Down","No")******
My additional query is:
If this item hadn't been uploaded yet, therefore there would be no date in the Date Listed cell, I would like to have an ISBLANK function which returns with "Not Required".
I have read something about ampersands and joining functions but not sure how to use them properly.
Here is what I have so far:
=IF(AND((TODAY()-G19)>31,ISBLANK(H19)),"Mark Down","No"), OR(ISBLANK(G19)),"Not Required")
Thanks again.