Question

I'm trying to make an automatic way to short an excel file field by name and date. I will explain what I'm trying to do:

I have an excel file where there is the log text of many users that have logged in the system during the last days. What I want to get out from this file is the first log in and log out in the system per day and per user. Here is an example:

Excel File

User1 - 20/01/2012 13:00 - 20/01/2012 15:27

User1 - 20/01/2012 16:00 - 20/01/2012 18:43

User2 - 24/01/2012 08:30 - 24/01/2012 11:43

User2 - 24/01/2012 15:32 - 24/01/2012 19:32

User2 - 25/02/2012 10:25 - 25/02/2012 15:25

User3 - 13/03/2012 04:13 - 13/03/2012 10:21

Result I want to get:

User1 - 20/01/2012 Login: 13:00 Logout:18:43

User2 - 24/01/2012 Login: 08:30 Logout:19:32

User2 - 25/02/2012 Login: 10.25 Logout:15:25

User3 - 13/03/2012 Login: 04:13 Logout:10:21

I'm not very sure how I should manage to get that in excel since my skill in excel are very limited. I would really appreciate any help.

Was it helpful?

Solution

Assuming this is what you intend to do:

Screenshot

Assuming this is what your data set looks like, you need to add two columns, Col 1 and Col 2 after your data set

In cell F2 enter the following formula:

=A2&B2

This will create one string which contains both username and date in 'Col 1'. Modify the formula to use the actual cell addresses if you need to. Copy this formula as far down as you have your data.

In cell G2, use the formula:

=IF(COUNTIF($F$2:F2,F2)>1,0,1)

I am assuming here that the data that you have will always be in chronological order. Please update your question if this assumption is not valid. This will output a '1' if it is a row you require. Copy this formula as far down as you have your data. It looks up the first occurrence of the combined string in Col 1. You can now do the following to get only the rows you require.

Click on cell G1. Go to Auto filter. In Excel 2003, this is accesed by Data->Filter->Autofilter. Select the option that says '1'. This will only leave the rows which show a 1 in Col 2. These are of course the rows that you want, as seen in the screen shot.

If any of this is not clear, please feel free to comment.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top