Solved

# Of Years Calculation

Posted on 2016-08-30
44 Views
Hi there,

I am attempting to calculate consecutive years in the attached file - for each year of activity the value is "1" if no activity the value is 0.

From Right to left (2015 to 1987) if there is a value of 1 then continue to move to the next column to the left.  If the value is 0 then return the column header year and discontinue any calculations.

Attached is the file layout - let me know if there are any questions on what I am asking.  I usually do this in crystal reports but am hoping to get away from the labour-intensive setup.

Thanks very much - CS
EE-Sample.xlsx
0
Question by:rporter45
• 5
• 2

LVL 28

Expert Comment

ID: 41776345
Are you trying to calculate col. AG?
If so, you may use the following formula to get the desired output in col. AG...
``````=COUNTIF(B2:AD2,1)
``````
and copy down.
0

LVL 28

Accepted Solution

Subodh Tiwari (Neeraj) earned 500 total points
ID: 41776372
If you are trying to return the header year from the right where it encounters the first zero, you may try this.....

On Row2 of a blank column
``````=INDEX(\$B\$1:\$AD\$1,MAX(INDEX((B2:AD2=0)*(COLUMN(\$B\$1:\$AD\$1)-COLUMN(\$B\$1)+1),)))
``````

And if you are interested in header year where the last consecutive 1 is found from the right, try this...
``````=INDEX(\$B\$1:\$AD\$1,MAX(INDEX((B2:AD2=0)*(COLUMN(\$B\$1:\$AD\$1)-COLUMN(\$B\$1)+1),))+1)
``````
0

LVL 31

Expert Comment

ID: 41776384
The way I read your question is that you are trying to find the most recent year of inactivity.

ID      Year
100   1997
200   1996
300   1996
etc

Is that correct? Not sure how you would do it with current layout.

Thanks
Rob
0

LVL 28

Expert Comment

ID: 41776396
@Rob
That is what the first of the two formulas from my previous post does. :)
0

LVL 31

Expert Comment

ID: 41776436
@Neeraj - I hadn't refreshed while entering my comment so didn't see your post. I was posting to confirm interpretation of the question. If our interpretation is correct then hopefully your solution will be what is required.

Thanks
Rob
0

LVL 28

Expert Comment

ID: 41776517
No Problem Rob!
Actually your post confirmed that I was thinking in the right direction. :)
Now it's up to OP to confirm whether this was the original request.
0

Author Closing Comment

ID: 41776524
This worked perfectly! Saves me a ton of time - very much appreciated,

Have a great day,
Colleen
0

LVL 28

Expert Comment

ID: 41777063
0

Featured Post

Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…