Count back or forward based on (moving) zero cell?

jmpatrick

Active Member
Joined
Aug 17, 2016
Messages
477
Office Version
  1. 365
Platform
  1. Windows
I'm struggling to create a formula that will count positive or negative numbers based off of 0.

Example: I have a column with 30 rows. If I put a zero in A10 I want A9 to show -1, A8 -2, etc. and A11 to show 1, A12 2, etc.. If I later put the zero in A15 then A14 should be -1, A16 1, and so on.

Make sense?
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Try using the formula:
Excel Formula:
=ROW()-10
and copy to all the rows in column A you want populated.
For your example, if you put that formula in all the cells, it will show the correct values you want.

Really, the format of the formula is:
=ROW() - x
where x = the row number you want zero in
 
Upvote 0
Try using the formula:
Excel Formula:
=ROW()-10
and copy to all the rows in column A you want populated.
For your example, if you put that formula in all the cells, it will show the correct values you want.

Really, the format of the formula is:
=ROW() - x
where x = the row number you want zero in

Doesn't work if I move the zero from one cell to another in column A.
 
Upvote 0
This might be a better example. I want to be able to move the zero from A10 to (for instance) A15 and have it still compute the positive and negative numbers.

zero.jpg
 
Upvote 0
Doesn't work if I move the zero from one cell to another in column A.
You would simply need to re-enter the formula and copy to all to reflect the new entry.

The issue is that cells in Excel can either have hard-coded values OR formulas, but never both at the same time.
So anytime you enter a new value into a new cell, you are going to have to do something to update all the other cells. Or have VBA do something for all the other cells.

If you want a VBA solution, please let us know exactly what ranges you want to restrict the "0" entry to, and what rows we should populate (i.e. where is the first and last cell located that would need to be populated?).
 
Upvote 0
A sequence of numbers from -ve to +ve hast to pass through 0, so I don't understand what you want.
 
Upvote 0

Forum statistics

Threads
1,215,523
Messages
6,125,318
Members
449,218
Latest member
Excel Master

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