HI I need a macro to count the # of occurrances based on some conditions. here is sample of the data table:

```
ID     Paydate        # of payments
1       5/1/2011            3
1       5/1/2011            3
1       3/1/2011            2
1       2/1/2011            1
2       6/12/2011           3
2       5/12/2011           2
2       4/12/2011           1
3       4/25/2011           2
3       3/25/2011           1

```

I want to count the # of payments a ID has made up to that date (the 3rd column is what I need). For example for ID =1 and paydate = 5/1/2011 there have been 3 payments, for ID=1 and paydate = 3/1/2011 there are 2 payments. The macro should count the number of payments less or equal to the current date and does not increase the count if there are multiple IDs with the same date. 

IF there is a way to do this with formulas that would be great but it seems too complex. Any help would be much appreciated.