# Months of inventory count

#### tdl

##### New Member
I have a bunch of estimated monthly sales and an existing inventory, I'm trying to calculate how many months of inventory I have. Here is a simple example:

 Inventory Jan Sales Feb Sales Mar Sales Apr Sales 100 90 10 30 10

So the answer would be 2.

I've tried a bunch of ways, any help would be great!

This was as close as I could get, but I'm getting an incorrect answer
=MATCH(B2,INDEX(SUBTOTAL(9,OFFSET(A2,,,,COLUMN(\$A\$2:\$BF\$2))),0))

This was the sample set I used and it doesn't work.
Units on hand: 3230
Sales #
 125 125 125 125 125 241 241 241​ 241 147​ 147​ 147​ 147​ 147​ 180​ 180​ 180​ 180​ 130​ 130​ 130​

#### vletm

##### Excel Ninja
tdl
eg without Your sample Excel file
... You would need to do a lot of changes to You Excel file, if someone will give an answer.

#### tdl

##### New Member
Sure here is a sample file

#### Attachments

• 13.5 KB Views: 5

#### bosco_yip

##### Excel Ninja
Maybe,

In C5,

=MATCH(C4,INDEX(SUBTOTAL(9,OFFSET(A2,,,,COLUMN(\$B\$2:\$BG\$2))),0))

Return : 19

Regards

tdl

#### tdl

##### New Member
Thanks. I've spent hours on this must have goofed. Any idea why A2 has to be blank? I tried extending this function to skip the first month and it blows up whenever A2 isn't blank.