VLOOKUP against helper column with date formatted as text? - excel

I'm using a vlookup against a table that has a generally-formatted column in the format "WORD NUMBER DATE" such as "Romeo 5M 06/16/2019". The reference is a helper column that I've created combining "Romeo" and "5M" and "06/16/2019". However, the date part needs to be formatted as text or else it won't match the lookup. This formatting is causing the #N/A error, despite a match. When I use =cell=cell2, it brings up "FALSE", given the formatting.
Help with this?
Thanks in advance.
I've already tried copy/paste formatting, and typing out the text in the cell makes the reference work so I'm assuming it's the formatting.

You can format the date in three separate cells. Assuming your date is in cell A1:
In Cell B1 - get the Year value
=YEAR(A1)
In Cell C1 - change the value to 2 digits if the month value is only 1:
=IF(LEN(MONTH(A1)) = 1, "0" & MONTH(A1), MONTH(A1))
In Cell D1 - change the value to 2 digits if the day value is only 1:
=If(LEN(DAY(A1)) = 1, "0" & DAY(A1), DAY(A1))
Then, in your aggregation formula, combine them like this:
= C1 & "/" & D1 & "/" & B1
If I'm reading your question correctly this should solve your issue.
Alternatively, if you need to change the cell format to text you may need to use vba code to perform some calculations for you which I can outline for you as well if this solution doesn't help you.

Related

SumIfs in Excel

I have a requirement to sum all the cells in a column from a sheet called Raw Data. But only if a few conditions exist.
The value in Raw Data column B matches the value of a offset from the current cell
The Month of the date in Raw Data Column C is less than or equal to H2
The Year of the date in Raw Data Column C is less than or equal to H2
Here is the formula I have assembled thus far:
=SUMIFS('Raw Data'!$D:$D,'Raw Data'!$B:$B,OFFSET(INDIRECT(ADDRESS(ROW(), COLUMN())),0,-4),MONTH('Raw Data'!$C:$C),<=MONTH($H$2),YEAR('Raw Data'!$C:$C),<=YEAR($H$2))
It could be a simple syntax error, but I don;t think it is. I keep getting a generic "There is a problem with the formula" error.
Can I get some help?
With SUMIFS the range expects a range not an array so MONTH('Raw Data'!$C:$C) and YEAR('Raw Data'!$C:$C) will not work.
Also when the others are expecting a string so you must use quotes and concatenate the criteria: "<=" & value
In this case we want everything less than the 1st of the next month:
"<" & EOMONTH($H$2,0)+1
Use this:
=SUMIFS('Raw Data'!$D:$D,'Raw Data'!$B:$B,OFFSET(INDIRECT(ADDRESS(ROW(), COLUMN())),0,-4),'Raw Data'!$C:$C,"<" & EOMONTH($H$2,0)+1)

Need to convert a specific text format to date format MM/DD/YYYY

I have an export from Active Directory of user accounts in a .csv/Excel where the date created cell is of General format (text?) as follows:
20150903075605.0Z in cell A1 which I need to convert to Date format as MM/DD/YYYY. I believe the text translates into 2015/09/03 but I could be wrong.
What I have tried so far:
Remove the .0Z and it changes to 2.01509E+ 13. Then in the
neighboring cell (B1) I try =DATE(A1) which gives me a #VALUE
Tried =DATE(LEFT(C2,2)+100,MID(C2,3,2),RIGHT(C2,2)) but that gives me
an obscure date of 4/12/2020.
This formula coverts the value in A1 into a true number:
=DATE(LEFT(A1,4),MID(A1,5,2),MID(A1,7,2))
You should apply number formatting to the cells where the formula is used. The number formatting would be: mm/dd/yyyy. In Excel, number formatting is often the best way to deal with dates.
If you need text instead of a true date, then:
=MID(A1,5,2)&"/"&MID(A1,7,2)&"/"&LEFT(A1,4)
let's say that 20150903075605.0Z is contained in cell A1, then you can get the MM/DD/YYYY date format by the following concatenation:
mid(A1, 5, 2) & "/" & mid(A1, 7, 2) & "/" & left(A1, 4)
So here is what I did to fix this. First strip the .0Z out.
Cell A2: 20040330191012 converting this to date (MM/DD/YYYY) in B2 by typing in =DATE(MID(C2,1,4),MID(C2,5,2),MID(C2,7,2)) gives me 3/30/2004.
I am pretty sure this is correct but if one of you guru's can confirm, it would be deeply appreciated.

Nested function in excel formula

I am trying to get the count of cells in a column containing dates having future date.
The column values are in string format.
I have figured out the formula as :
=COUNTIF(G19:G31,">" & TODAY())
This function works when the column values are in date format. But its failing if the cell format is in string format.
I have figured out the formula to convert a cell string value to date :
=DATEVALUE(G19)
Here are my queries:
1) How to apply DATEVALUE on a range , in this case from G19:G31?
2) How to combine these two formulas in to one single formula?
You could use:
=SUMPRODUCT(--((G19:G31+0)>TODAY()))
COUNTIF will not accept anything other than a range as its first argument so you can't use functions there.
An alternative is to write =SUM(IF(DATEVALUE(G19:G31) > TODAY(), 1, 0))
But this will be an array formula: you need to press Ctrl + Shift + Return once you've done editing, rather than just Return.

Excel - Convert date from yymmdd to dd/mm/yy

I have an Excel file which is exported from a Access database.
I have 25000 records and I will need to replace all of them.
The date column is not formatted (yymmdd). I need to change the date format from yymmdd to dd/mm/19yy. For the yy I need to add a constant value 19 in front of it so it would be 19yy.
I have only 1 date column per row
Is there any way to convert all the 25000 record's column formatted in yymmdd to dd/mm/19yy in a few clicks?. Thank you
This will give you the result as an actual date which you can then format as you wish using Excel's date formatting options.
=DATE(1900+LEFT(A1,2), MID(A1,3,2), RIGHT(A1,2))
If you don't need to parse it into a date value, but merely need to display a date in the format you identified, the following will work on a value in cell A1 (copy down to the rest of the 25,000 values as needed:
=RIGHT(A1,2) & "/" & MID(A1,3,2) & "/19" & LEFT(A1,2)
In my cell A1, I entered the value 981116. This formula converted it to 16/11/1998. I think that's what you're looking for, right?
Assuming data starts at A2 put this formula in B2
=(19&TEXT(A1,"00-00-00"))+0
Now format B2 in required date format, e.g. mm/dd/yyyy
and you can easily "fill down" all 25000 rows by doing this:
put cursor on bottom right of B2 (first cell with formula) until you see a black "+" - that's the "fill-handle" - double click and the formula will populate as far down as you have continuous data in the adjacent column
Note: you can probably omit the 19& if all your dates are after 1930 because the default is to treat any date written without the century as 1900s if it's >=30 or 2000s if it's <30 [although you can change that in regional settings]

excel formula to combine 2 cells into 1 in specific format

I have 2 cells, one cell has just text A1 cell, text (hello) other cell B1 has a timestamp (3:55). I need to combine these cell to one with this format: hello#t=3m55s, or if timastamp is 1:12:11 format will be hello#t=1h12m11s. So cell A1 will change to this specific format base on B1 cell.
Thank you.
You could try this formula:
=A1&"#t="&IF(HOUR(B1)=0,"",HOUR(B1)&"h")&MINUTE(B1)&"m"&SECOND(B1)&"s"
The & concatenates each part together. However, if the timestamps are not correct for the mm:ss times, then it won't work.
EDIT: To deal with the issue of timestamps:
=A1&"#t="&IF(SECOND(B1)<>0,HOUR(B1)&"h"&MINUTE(B1)&"m"&SECOND(B1)&"s", HOUR(B1)&"m"&MINUTE(B1)&"s")
The issue with this is that it won't work for timestamps of the type "11:11:00" But I don't think there's much to be done, unless the string is first converted to text, which I could give some pointers on.

Resources