Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

Change date-time in a column

0

Hi.

I would appreciate advice on the following: I'm trying to find a way to differentiate info included in the cells of a column with 25000 rows, wherever the same cell appears, without changing the info given, excluding the seconds.

I need to compare it with similar columns in diferent sheets in the same file. The info included in the cells refers to airport timetable

Any ideas please?

  • Date

3/21/2019 12:39:08 PM

3/21/2019 12:51:00 PM

3/21/2019 1:04:00 PM

3/21/2019 1:04:00 PM

3/21/2019 1:04:00 PM

3/21/2019 1:35:00 PM

Thank you in advance

Katerina

PS The main problem is that vlookup doesn't work properly for the above and 325 more days

Answer
Discuss

Discussion

Katerina

I provided an Answer but perhaps I missed your intention (if so I'll delete or amend it).

To help me (and others), please edit your original question to give a better idea of the outcome you're looking for. You can use the "Add files..." button below the question text to provide an Excel file to show us the data you're working with.
John_Ru (rep: 6152) Feb 6, '21 at 7:12 am
John 

thank you for your reply.! I m working on it and will come back to you with the results soon
kdimi (rep: 2) Feb 6, '21 at 7:16 am
Katerina

Are you looking to lookup a particular  flight time/date or just highlight all flights with the same date/time?
John_Ru (rep: 6152) Feb 6, '21 at 8:08 am
I have to check columns with various data, among 5 sheets.
Last night I read Don's turorial about vlookup, the one you suggested.It was really helpful. Lookup_value is "flight date" 
The problem is that I have 326 same dates and times. I have done the best part of job so far and I'm not sure how to continue. No need to mention that i'm in a hurry with the file

Thanks a lot
kdimi (rep: 2) Feb 6, '21 at 8:28 am
So what do you want to achieve here? If its to highlight the ones with same date time, I has an idea... 
John_Ru (rep: 6152) Feb 6, '21 at 8:54 am
E.g. do you want same flights listed in another sheet? 
John_Ru (rep: 6152) Feb 6, '21 at 8:59 am
No. I want vlookup formula to work properly and give correct results for all lines in the columns. For the time being and because of the same, absolutely same even to the second, dates and times, it returns the first one which appears in searching. But the correct one supposed to be the second or third line I mean flight date. The date and time are exactly the same but rest of data are different. eg airlines, pax etc
In which way I could match the correct flights with all relevant data? 
I m not sure I'm clear enough so do you want me to try to upload few lines of my file, cause its big enough?
kdimi (rep: 2) Feb 6, '21 at 9:08 am
I'm not clear (yet). Please upload a sample file (in the original Question) and show an example of a lookup you want.
John_Ru (rep: 6152) Feb 6, '21 at 9:21 am
Thanks for the file but I'm still not clear what your'e trying to do. Are you tring to find a given flight on a date (in which case I assume you also know the flight number say) or all those flights where there is an unpaid amount (i.e.. Paid does not equal Total in "ncr")?
 
In "ncr", two entries have the exact same time so your VLOOKUP will return only the first value, as you have found. What other information do you know to add to the search? Flight code?
John_Ru (rep: 6152) Feb 6, '21 at 10:37 am
I want to be sure that all lines from sef and acf sheets are included in ncr sheet. Unique cell is flight date and time. Unfortunately the rest of columns are repeated through a 12 months period.

Also I have to check Pax and values. Main sheet is ncr and the other two comes from a diffrent file. 

Cannot figure out any other way to check it except lookup formula
I thank you for your time and help. 
kdimi (rep: 2) Feb 6, '21 at 10:56 am
See Revision 1 of my Answer. Sorry but I have no more time today.
John_Ru (rep: 6152) Feb 6, '21 at 12:08 pm
Hi Katerina. Did that help?
John_Ru (rep: 6152) Feb 8, '21 at 4:34 am
I let you know later John
thank you for your support
kdimi (rep: 2) Feb 8, '21 at 4:40 am
Thanks for slecting my Answer, Katerina.

I tweaked it just to clarify that the formula matches Flight Date (updtd), Reg.No., Company name and Flight code with entires in "ncr".
John_Ru (rep: 6152) Feb 8, '21 at 4:41 am
Add to Discussion

Answers

0
Selected Answer

Hi Katerina and welcome to the Forum.

Not sure HOW you want to "differentiate" between the seemingly similar times (using a formula, conditional formatting, via VBA etc.) but Excel stores dates/times as numbers. The formatting of the cell may make times looks the same (though they actually  differ by seconds in reality).

For example, my formatted cell shows "06/02/2021  09:07" (in UK format) but clicking in the cell shows the seconds "06/02/2021  09:07:00" in the formula bar and formatting the cell as a Number reveals (on clicking) the stored number as 44233.3798611111.

The numeric value for a similar looking cell but just one second later is 44233.3798726852. Both numbers look the same (in the sheet) but are quite different. This is detailed in Don's tutorial Vlookup on Dates and Times in Excel

Taking the simplest way to "differentiate" between date/times, you could calculate the time in seconds between dates in your column using this simple formula (but changing the cell references in bold):

=(A5-A4)*86400
Be sure to format the result cell as a Number not General (and adjust the formatting for number of decimal places to suit yourself).

That formula just subtracts the two date/time numbers (which are fractional numbers of days) then multiplies the result by the number of seconds in a day (24*60*60=86400) to give the number of seconds.

Hope this helps.

REVISION 1: If your looking to check if rows in one sheet of your file are matched in another sheet ("ncr"), the worksheet function COUNTIFS can be used.  In my revised file (attached), I've left your VLOOKUP formula in the first 2 or 3 rows of sheets SEF and ACF but copied some values into some additional rows below (and for demo purposes, I've changed some bits to create mismatches). In new column J of SEF, I've used this formula (e.g. in cell J2):

=IF(COUNTIFS(ncr!A:A,A2,ncr!F:F,B2,ncr!D:D,D2,ncr!E:E,E2)=1,"Y","Not found or duplicated in NCR")
and likewise in sheet ACF.

The COUNTIFS part (in bold) counts the number of entries in ncr which match certain parts of row 2 in SEF. Each pair of arguments comprise a lookup range and a criteria (=value) e.g. the pair "ncr!A:A,A2" is TRUE if A2 is found in ncr column A. Likewise for B2 is found in ncr column F etc. Each time all pairs are TRUE-i.e. (Flight Date (updtd), Reg.No., Company name and Flight code all match- it counts as 1. For a unique match, COUNTIFS would return the value 1; 0  if it's not matched or 2 if it's found twice etc.

Accordingly I've wrapped that in an IF function which just says Y is there's a uniqure match and a warning if it's not found (I've also added conditional formatting so the text in the columns are bold and red if the formula doesn't return "Y".

Hope this makes sense and works for you. Suggest you change some values (or correct them to see that it works.

Discuss


Answer the Question

You must create an account to use the forum. Create an Account or Login