Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Moving a row up or down whilst keeping the equation the same.

Quite often, on my personal banking form, a payment happens on a different day that original forecast & I have to drag the row up or down.


Unfortunately this means that the formula gets messed up & I have to drag down the bottom edge of a cell in each of the different columns across the spreadsheet to "iron out" the wrinkles.


Specifically, I have four bank accounts/cards running across the spreadsheet. Each of these has IN, OUT & TOTAL columns. The formula effectively says "take the sum of the previous row's TOTAL, add anything in the IN column, subtract anything in the OUT & give me a new total in this row's TOTAL column".


Unfortunately, each cell reference is cell specific so rather than an expression that refers to, for example, "the row above", it says something like T13. So when I drag a row up or down, the "from" value moves with it, so that my expression now effectively says "take from that cell ten rows up"!!


How can I (or rather "can I") make it so that the formula stays the same regardless of where I drag a row to?

iPhone 8, iOS 11.2.6

Posted on Sep 28, 2018 6:33 AM

Reply
Question marked as Best reply

Posted on Sep 30, 2018 6:07 AM

del.frost wrote:


trying to ascertain whether it's possible to write a formula that looks to the "cell above" as a source figure but doesn't follow that cell to where it now is, if it's beed dragged.


Yes, that's possible. In your Total columns you could use the OFFSET function, like this:


User uploaded file



In G5, filled down the column:


=OFFSET(G5,−1,0,1,1)+E5−F5


But, since your screenshot suggests you are working with quite a large table, you may find that using OFFSET in so many cells makes your document sluggish. If that happens, it would be because OFFSET is a so-called "volatile" function that recalculates every time you make a change to the document.


SG

Similar questions

15 replies
Question marked as Best reply

Sep 30, 2018 6:07 AM in response to del.frost

del.frost wrote:


trying to ascertain whether it's possible to write a formula that looks to the "cell above" as a source figure but doesn't follow that cell to where it now is, if it's beed dragged.


Yes, that's possible. In your Total columns you could use the OFFSET function, like this:


User uploaded file



In G5, filled down the column:


=OFFSET(G5,−1,0,1,1)+E5−F5


But, since your screenshot suggests you are working with quite a large table, you may find that using OFFSET in so many cells makes your document sluggish. If that happens, it would be because OFFSET is a so-called "volatile" function that recalculates every time you make a change to the document.


SG

Sep 28, 2018 12:41 PM in response to del.frost

del.frost wrote:



"take the sum of the previous row's TOTAL, add anything in the IN column, subtract anything in the OUT & give me a new total in this row's TOTAL column".


Unfortunately, each cell reference is cell specific


This doesn't eliminate the problem entirely, but it does make it easier to "adjust" formulas after you drag a row up or down. Use a formula with "expanding ranges" rather than specific cell references, as in this simplified example:


User uploaded file


The formula in D3, filled down:


=SUM(B$2:B3)−SUM(C$2:C3)


The formula in G3, filled down:


=SUM(E$2:E3)−SUM(F$2:F3)


Then, after you drag rows into a new position, just fill the formulas down again from row 3. That's easier than adjusting each formula in each row, one by one.


SG

Sep 29, 2018 5:35 AM in response to Yellowbox

User uploaded file


Here's a screenshot of my spreadsheet.

The four accounts run left to right across the top with "in", "out" & "total" columns for each, along with a "credit limit" column for the two credit cards in order to obtain the "available credit" total, making 5 columns each for the credit cards.

The entries in the "item" column are in chronological order & are colour coded to show which account they're for.

The entries in the "in" & "out" columns are coloured pink once they have cleared on the statement. Uncleared transactions are left in black until they clear.

The green cells show that the total agrees with the bank statement in each case.

Entries in grey are expected future transactions with amounts that vary. They will be adjusted if necessary, coloured black once they hit my account & then pink once they're cleared. If an entry in grey doesn't happen on the day I expected it to (if it falls on a Sunday, for example & the transaction happens on the Monday or if I pay a bill on a different day than I'd planned to) then I'll need to drag it to the correct day, select a cell from further up the table & drag down on the yellow dot at the bottom of the cell to "iron out" the formula & get it all working properly again. Of course, I then need to do this on each of the columns that have such a formula.


As the days go by, I add in rows to insert each transaction that happens in each account, whether that's shopping or perhaps moving money between the accounts.


I recently managed to find out that if every cell in a column contains the same formula, then I don't have to go across every column & drag a cell down to join the gaps, which saves me heaps of time.


As you can hopefully see in the screenshot, the formula looks to the cell above for a starting amount. I'm now trying to ascertain whether it's possible to write a formula that looks to the "cell above" as a source figure but doesn't follow that cell to where it now is, if it's beed dragged.

Sep 30, 2018 1:06 PM in response to del.frost

INDIRECT(ADDRESS()) is another way to refer to a cell.


User uploaded file


If B is "In" and C is "Out" and D is "Total", a formula for column D that would do what you are asking is

=INDIRECT(ADDRESS(ROW()−1,COLUMN()))+B−C

Except for the first row of column D which would be

=B-C (or simply a number you enter as the beginning balance)

and should not be moved.


I don't know if this is computationally faster or slower than OFFSET on larger tables or if all those ROW and COLUMN functions are slow to get recalculated.

Sep 28, 2018 7:54 AM in response to del.frost

Hi del,


I don't think that dragging rows is the way to go. Leave your personal banking form (table) intact.

Try using the SUMIF or SUMIFS functions in other tables.

Then you can calculate the bank balance for each account.


The Numbers approach is to "pull" data from a large table into small tables, each table having a purpose.


A screen shot (hide personal data) of your personal banking form will help us to see what you see.

Click on the table to make it active. Then it will show row and column labels. Please include those labels in the screenshot.


The more information you give, the easier it will be for fellow users to find a solution 😉.


Regards,

Ian.

Sep 28, 2018 8:23 AM in response to Yellowbox

Thanks for the reply, I'll try to get that sorted this evening.


One thing about what I need is a single spreadsheet showing each of my accounts side by side with all transactions in chronological order, including all past transactions for the year & projected cashflow until the end of the year. I'm not sure that sending data to other tables will achieve that but I'm open to ideas.

Sep 29, 2018 4:27 AM in response to del.frost

Hi del,

what I need is a single spreadsheet showing each of my accounts side by side with all transactions in chronological order, including all past transactions for the year & projected cashflow until the end of the year.

OK, lets go with a single table. SG's solution of "expanding ranges" is excellent and I agree with that approach.


I am still trying to visualise a single table of several accounts, each in chronological order. Does each bank report arrive on the same day? Are all accounts included in a single table? Do you edit that table to match SG's example?


I do not understand the need to drag rows up or down. That drags whole rows.

Numbers mimics a database. In a single table, each row is a record; each column is a field.

Please help us to help you with a screenshot (anonymous data).


Regards,

Ian.

Sep 30, 2018 6:08 AM in response to del.frost

Hi Del,


Try this on a COPY of your table:


Instead of dragging a row up or down, Insert a new row in the correct location, Copy the entered data from the misplaced row, Paste that data into the new row, then delete the misplaced row.


Depending how your formulas are constructed, Numbers should automatically adjust formulas to handle the insertion or deletion of these rows, provided you copy and paste only the data that has been entered.


Regards,

Barry

Sep 30, 2018 6:07 AM in response to Barry

Thanks for your reply.


Yes, numbers "should" behave like that & the reason it doesn't, I assume, is that my formulae aren't constructed properly. Which is what I'm hoping to learn here.


At the moment, if I were to do as you suggested, when I delete the row, every cell onwards from the deleted row would contain a warning triangle because it's lost its source cell.

Oct 1, 2018 5:50 AM in response to SGIII

This worked perfectly & doesn't seem to slow anything down noticeably. Thanks!


I've turned the "available balance" into a formula referencing the previous cell so that adding rows doesn't leave a gap (now that I know that having the same formula in every body cell copies the formula down when I add a row).


Now that there's no previous cell to reference, I also don't get the warning triangles when deleting a row.


So, dragging down the little yellow handle to "heal" messed up columns across 4 accounts every five minutes is now a thing of the past.


Thanks everyone, for your help & contributions.


SGIII, I clicked on "solved" but it doesn't seem to have done anything.

Moving a row up or down whilst keeping the equation the same.

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.