#### amkerchner

##### New Member

- Joined
- May 23, 2007

- Messages
- 10

The formula is as follows:

=IF(ISERROR(IF(AND(D2=D3,D3=D4,D4=D5),((I2*J2+I3*J3+I4*J4+I5*J5)/SUM(J2:J5)),(IF(AND(D2=D3,D3=D4),((I2*J2+I3*J3+I4*J4)/(SUM(J2:J4))),IF(D2=D3,((I2*J2+I3*J3)/(SUM(J2,J3))),I2))))),"",(IF(AND(D2=D3,D3=D4,D4=D5),((I2*J2+I3*J3+I4*J4+I5*J5)/SUM(J2:J5)),(IF(AND(D2=D3,D3=D4),((I2*J2+I3*J3+I4*J4)/(SUM(J2:J4))),IF(D2=D3,((I2*J2+I3*J3)/(SUM(J2,J3))),I2))))))

And I need it to run each time I click the button I've made. Any suggestions? I am attempting to take the weighted average of cost when there is a repeated number in column D.