Hello,

I'm a pretty lousy programmer and I'm not sure if this is possible but here's my problem:

I have three columns:

Trial, TreeID, Nback


So the value in Nback should be equal to the difference in trial numbers between the current TreeID and the last time that same ID occured. So it should look like this:

Trial, TreeID, Nback
1 1 0
2 2 0
3 3 0
4 3 1
5 2 3
6 1 5
7 2 2
8 3 4


So the number in the TreeID can be anything in a certain range, with no set order. Is there anyway to make a function for the Nback column so that I don't have to go through and calculate each cell myself or this not possible in excel?

Thanks!