Suppose that we have columns "A" and "C" and "D" like this:

1.JPG

How to fill column "B" using each value's frequency noted in column "C" and "D" like this:

2.JPG

I have a column of 400k records with 8k independent values. I can get the frequency list using pivot table by my self, but can't expand it the way I asked.
Thanks for your help