If particular cell is NOT BLANK copy down FORMULA from above cell - conditional-formatting

Basically I have the following formulas:
Column J: =IF(ISNA(VLOOKUP(I2,CCG,1,FALSE)),"Out of Area",VLOOKUP(I2,CCG,1,FALSE))
Column K: =INDEX(ResponsibleAgency,MATCH(N3,LeftLookup,0),MATCH(J3,TopLookup,0))
Column L: =IF(ISNA(VLOOKUP(N3,PPLookup,2,FALSE)),"Missing F Code",VLOOKUP(N3,PPLookup,2,FALSE))
Column M: =IF(ISNA(VLOOKUP(N3,PPLookup,3,FALSE))," ",VLOOKUP(N3,PPLookup,3,FALSE))
Basically, I only want these formulas to activiate provided that column A is populated with a date. If there is no date in column A, I want the cells to remain blank.
Is this possible?

Technically speaking, it is not possible to tell if cell contains a date or not in strict sense.
In Excel dates are in fact numbers representing number of days since January 1, 1900. I.e. today is 42066. It's the formatting that makes those numbers look like dates to user. If you pass a cell containing a date to any formula, it receives this number.
As a workaround, you can check if the cell satisfies two conditions:
It is a number.
It falls into some date range that makes sense.
For example, if your column contains goods delivery dates you usually don't expect them be previous century or 50 years into the future.
So you can wrap your formulae into something like this:
=IF(ISNUMBER(A1),IF(AND(A1>=DATE(2014,1,1),A1<=DATE(2015,12,13)),[LOGIC_IF_CORRECT_DATE_HERE],""),"")
Being said, it's still a workaround.

Related

vlookup to pick the nearest date lesser date from the reference cell

I required your support,
I have a datasheet (Sheet1) which is having product details and its dates which are been imported. Another sheet (Sheet2) which are also having product details and its dates which are been exported by the seller. Both the sheet dates might not be equal nor the total no. of rows will be the same.
I wanted to understand if a Vlookup can compare the dates of sheet 1 & sheet2 for each product keeping the imported dates of sheet 1 as a reference and pull the nearest lowest date from the sheet2 "created date"
Sheet 1 is having the data which is from imported data
Sheet 2 is the date which shows the actual export from the seller
So now I need to do a comparison for the Product bearing (cell A2) from Sheet 1, which is having the imported date as of 10/22/2019. Comparing to the next Sheet2 (Image 2 ) for the same product bearing which is having the created dates as 10/18/2019, 11/08/2019,10/16/2019.
The formula should now pick a date which is nearest lesser to the imported date which is in the sheet1. in this case, formula to pick the date 10/18/2019.
I tried to sort the data to lowest to highest and highest to lowest, but v-lookup results were not always right. I tried to insert the IF condition resulted in no luck.
It would be very helpful if you all share some insight into this case.
Thank you for reading the above case.
Use AGGREGATE:
=AGGREGATE(14,7,B2:B100/((A2:A100="Bearing")*(B2:B100<=Date(2019,10,22)),1)

How to filter an excel columns which contain date/time as string

I have an excel sheet to filter a Column. The column relates to total experience of a person. The values are like 5years 2Months, 32Years 6Months etc... all the values are in String format. I need the following functionality.
when i enter >5 in a textbox(which i will create in a form), it should display only experience which are less than 5(filtering) . I need an idea how to do this in vba.
Can anyone help..? I just need a way to do this.
Consider the following screenshot. Column a has the unfortunate text with years and months.
Column B splits out the years. Column C splits out the months. Column D has the total number of months for the time frame. With this in place, you can filter by any of the columns using the filter options of the Autofilter built into an Excel table.
The formulas are as follows:
Years: =MID([#total],1,FIND("Years",[#total])-1)+0
Months: =MID(SUBSTITUTE([#total],"Months",""),FIND(" ",[#total])+1,99)+0
Duration in months: =([#years]*12)+[#months]
Now just use the filters in the drop down butttons of the column headers and there is no need for VBA at all.

Look back through a row and find the last time I wrote a particular word

I have a table that I am creating in relation to toolhire and I have many columns for on hire / off hire / days utilised. in the columns next to the on hire and off hire dates, I have it set to write the words ON and OFF when a date is entered into that cell. I want to set up a column at the end of the table which will look back through the row and tell me whether the item is currently ON or OFF by finding whether the last word it finds is ON or OFF.
If a row spans ColumnsA:M say, and contains only blanks, numeric values or ON or OFF then please try, say in ColumnN and for Row2:
=INDEX(A2:M2,MATCH("zzz",A2:M2))

Excel, automatically updating variable in IF statement based on reference cell?

I have a sheet that needs to be updated monthly with a formula that needs to change with the month.
This is the formula: =IF($S3=AI$1,[#July],0)
The check is to make sure my values go into the correct category. After the category is determined correct, I need to take the month's values by referencing the month column in my table.
Question: Is there any way to make it so when I change the month somewhere, I can make the formula essentially move over a column to take the new month's values?
Note: I also have a similar case where instead of taking the month values verbatim, I'm summing the year's values til said month.
So I assume you have a table with column name January to December.
You can do this in at least two ways (I assume your month number is in cell A1)
Explicit: (in case these columns are not in order or adjacent to another)
=CHOOSE(A1,[#January],[#February], ... ,[#December])
Implicit: (if the months are next to each other:
=INDEX(TableName[#[January]:[December]],A1)
Obviously, I'd recommend the second option, if applicable.
If you want to sum from januar to the current month, you can use this little know trick/syntax:
=SUM([#January]:INDEX(TableName[#[January]:[December]],A1))

Find a previous date on a list closest to a specified date

I would like to have VBA code or formula that will take a variable date value and find it on a list range of dates. If it can't find the date I want it to find the closest previous date value. VLOOKUP works great for finding an exact match but I am struggling with the code to find the closest previous date.
My only thought is to create a loop where if it doesn't match it continues to subtract a day from the variable date until it can locate a match on the list. That does not seem like the best or most efficient method and I hope someone can recommend a simpler solution.
Example:
Variable Date = 01/26/2014
Date List
02/04/2014
01/27/2014
01/24/2014
01/13/2014
12/29/2013
Desired Result = 01/24/2014
Any help would be appreciated.
Suppose your list of dates was in cells A1:A5 and your check date was in cell C1, you could enter this function ENTERED AS AN ARRAY FORMULA:
=MAX(($A$1:$A$5<=C1)*A1:A5)
Rememeber, to enter it as an array formula, hit Ctrl + Shift + Enter when entering the formula.
Hope this does the trick!!
I went about this a little differently, no arrays needed
Find how many numbers are bigger then the one you are looking for with CountIf()
Then I used =Large this will find the nth dates in a list we have the nth we are looking for in the countIF()
=LARGE(A:A,COUNTIF(A:A,">="&TODAY()))
Vlookup can do this actually, if you set the final argument to true, which looks for an approximate match. You need your dates sorted from Oldest to newest and it will return the first date that is not after your search term.