# Increment a cell value - conditions applied

Solved/Closed
peweuk Posts 3 Registration date Sunday February 1, 2015 Status Member Last seen February 5, 2015 - Feb 1, 2015 at 08:26 AM
peweuk Posts 3 Registration date Sunday February 1, 2015 Status Member Last seen February 5, 2015 - Feb 1, 2015 at 01:01 PM
Hello,
I needed a formula to add a value to a cell when the cell next to it contains a value where that value is obtained by incrementing the value in the previous cell by 1.

I used the following formula:

=IF(B4<>"",A3+1,"")

Example.
A3 contains a value of 1.
The formula in A4 monitors cell B4 and if a value is entered in B4 then a value is placed in A4 which equates to A3+1 (ie value of 2).

This works well enough as seen in rows 3-6 above, BUT when the previous cell in column A contains no value - such as cell A in row 7 in the example above, the formula no longer works in cell A8

What I need to do is somehow amend the formula (or use some other method) so that the cell which is incremented in column A is the last one in the column which contained a value.

I hope this all makes sense and wonder if anyone can assist with suggestions for a solution?

TIA

Related:

## 1 response

RayH Posts 122 Registration date Tuesday August 31, 2010 Status Contributor Last seen June 20, 2016 26
Feb 1, 2015 at 12:01 PM
in Cell A4 and drag down.

=IF(B4<>"",IFERROR(COUNTIF(B\$3:B3,"<>")+1,""),"")
peweuk Posts 3 Registration date Sunday February 1, 2015 Status Member Last seen February 5, 2015
Feb 1, 2015 at 01:01 PM
Excellent - it works beautifully.
Much appreciated.
It would have taken me ages to come even close to a formula like this. ;)