# Formula to add up quantities depending on number of weeks

1. ## Formula to add up quantities depending on number of weeks

Hi all.

I've been fighting with an Excel file all day and I am in need of help. I attache a simplified version of the file.

There are 3 main factors: the number of weeks (displayed in Sheet 1), the quantity for each week (displayed in Sheet 2) and the number of the project.
If the number of weeks needed is 4, then it must add up 4 columns from Sheet 2. If the number is 10, then it must add up 10 columns, and so on. So far, I've come up with the following formula:

=SUM(OFFSET('Sheet2'!,\$A\$3:\$A\$31,0,1,1,\$B25))

Now, I want to match the number in the PN column with the one in Sheet 2 and as a result, obtain the sum that goes with each PN number. And here is where I request some help. I've tried with some VLOOKUP but I wasn't able to get anything.  Register To Reply

2. ## Re: Formula to add up quantities depending on number of weeks

in F6

=SUM(OFFSET('Sheet 2'!\$A\$2,MATCH(\$A6,'Sheet 2'!\$A\$3:\$A\$31,0),1,1,\$B6))

copy down  Register To Reply

3. ## Re: Formula to add up quantities depending on number of weeks

Thank you so much for your help John!!  Register To Reply