Incremental values based on Column value and row

It_thug

Registered User.
Local time
Today, 06:02
Joined
Oct 22, 2009
Messages
59
What I need, is to populate a column with incremental number based on 1 column and the previous rows result.

Will be easier to see it.

Let's says I have the following:
ID_NUM RPT_YR CS
1 1989 0
1 1990 0
1 1991 1
1 1992 1
1 1993 1

I need a column that will increase like so:

ID_NUM RPT_YR CS Increment
1 1989 0 0
1 1990 0 0
1 1991 1 1
1 1992 1 2
1 1993 1 3
1 1994 0 0
1 1995 1 1

This is where it increments based on a value existing in the current row, and increases for each row that contains the value, resetting it's self when the current row is 0 or Null.

Since I don't know exactly how to phrase what I'm asking, I haven't had much luck looking for code for this.
 
If this is EXCEL then it is a simple formula althougth one has to be careful of the first entry, it needs an empty cell before it.
Assuming your columns are A-D then in D starting in row 3 to allow for headings and a blank row
=IF(OR(C3=0,C3=""),0,1+D2)
and fill down.

Brian
 
If this is EXCEL then it is a simple formula althougth one has to be careful of the first entry, it needs an empty cell before it.
Assuming your columns are A-D then in D starting in row 3 to allow for headings and a blank row
=IF(OR(C3=0,C3=""),0,1+D2)
and fill down.

Brian


Thank you for your answer. I didn't mention that this would be for VBA in Access. However, that being said.... for what I'm doing, I think doing it in Excel is absolutely a valid option, and may be a lot easier than what I was working towards.
 

Users who are viewing this thread

Back
Top Bottom