Increasing values by one

You have a list of values in Excel. All the values which are not empty should be increased by one.

1

1

1

2

Should be

2

2

2

3

You can fill the new values in the cell next to the values with IF-function =IF(B2>0;(B2+1);””) .The correct values are populated next to the original values.

If you don’t want to have an additional column, but original values should be overwritten by new values, you can also execute the macro below.

sub z_plus_one2()

Dim cell As Range

For Each cell In selection

If cell.value > 0 then

cell.Value = cell.value +1

end if

Next cell

End sub

Activate the values and execute the macro.