Count Columns between first populated cell and last populated cell

dversloot1

Board Regular
Joined
Apr 3, 2013
Messages
113
Hello,

I've got sales data by item by year. Items are listed in rows, and their sales by year are in columns. I'm trying to calculate the lifespan of products; Last Year Item was sold - First Year Item was sold. I thought I could use a counta function but I noticed that there were years that had no sales.

I know what I need to do but not sure how to do it.

Get the column number of the last recorded sale, minus the min column of a recorded sale.

Any ideas?

Values are in columns C:O
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
2001200220032004200520062007200820092010201120122013
ASSY303R447_12F2
ASSY303R449_9F8
ASSY303R454_9F7
ASSY303R455_5F5
BUNDBAVARBUNDPKG4
BUNDFUVARBUNDPKG21
CABL012R1585161
CABL110PATCH12A-1
CABL5VPOWERTAP873
CABL69900021160
CABLBLANKPATCH3237122
CABLBLANKPATCH480
CABLCABLSIGN41
CABLCC10MM-34-9-2326-1

<tbody>
</tbody>
 
Upvote 0
I was able to come up with this by doing some more research. It seemed to calculate what I wanted.

=MAX(IF(C2:O2<>"",$C$1:$O$1))-MIN(IF(C2:O2<>"",$C$1:$O$1))+1
Cntl+Shift+Enter
 
Upvote 0

Excel 2010
ABCDEFGHIJKLMNO
12001200220032004200520062007200820092010201120122013#years
2ASSY303R447_12F21
3ASSY303R449_9F81
4ASSY303R454_9F71
5ASSY303R455_5F51
6BUNDBAVARBUNDPKG41
7BUNDFUVARBUNDPKG212
8CABL012R15851611
9CABL110PATCH12A-11
10CABL5VPOWERTAP8733
11CABL699000211601
12CABLBLANKPATCH32371223
13CABLBLANKPATCH4801
14CABLCABLSIGN412
15CABLCC10MM-34-9-2326-16
Sheet3
Cell Formulas
RangeFormula
O2{=INDEX($B$1:$N$1,1,MATCH(9.99999999999999E+307,B2:N2))-INDEX($B$1:$N$1,1,MATCH(TRUE,B2:N2<>"",0))+1}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0

Forum statistics

Threads
1,216,069
Messages
6,128,599
Members
449,460
Latest member
jgharbawi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top