Hi, I was wondering if there was a formula to automatically allocate cost. I have included a picture of what I am trying to do. The columns in "BLUE" have the department cost for bonuses being alloted for employees. Each department has a department code. Each department has to pay a portion of the bonuses so what I want to do is to see if there is a formula that would automatically evaluate all the employee bonus payouts in "GREEN" and assign the department code in the first column of the green columns so they would add up to the amount allocated to each department in the blue columns. Thank You