Dear all,

I am currently busy with making a VBA to calculate average elapsed times but I do not succeed and have no idea how to begin.

I have an excel file with 4 columns (see picture):Untitled.png
A: Name
B: Date
C: Time
D: Phase

I want to find the average time that a person belongs to a certain phase, so:
The average time elapsed in phase 1 is the difference between the time stamp that a person goes to phase 2 and the the time stamp that that same person goes to phase 1.
As in the picture: the time between John going to phase 1 and to phase 2.

However, my original excel file contains far more rows and contains some difficulties making it me hard:
-Not everyone goes to each phase, as in the picture: Luke goes only from 4 to 5 so this time only belongs to the average time a person stays in phase 4.
-It is possible that a person does not go to successive phases during the time. As in the picture: George goes to 3 on 04-16, to 4 on 04-17 but goes to phase 2 on 04-18 which does not belong in the calculation. Only the time that George stays in phase 3 and 4 needs to be calculated in the average. The other time stamp needs to be neglected since these are not successive phases.

Hopefully someone is willing to help me since I really do not know where to begin.

Thanks in advance!

Melvin