SOLVED

Inconsistent formulas in table

Copper Contributor

On my table when I add a new row by using the tab function my last formula before the new row changes and skips the new row. For example: =IF('Water Usage'!D28-'Water Usage'!$D27<0,0,'Water Usage'!D28-'Water Usage'!$D27) is the formula but when I tab for a new row the formula changes to =IF('Water Usage'!D30-'Water Usage'!$D28<0,0,'Water Usage'!D30-'Water Usage'!$D28). 

 

It completely skips D29. The correct formula should be: =IF('Water Usage'!D29-'Water Usage'!$D28<0,0,'Water Usage'!D29-'Water Usage'!$D28).

 

But when I just input my data below the last row the table grabs that row including it into the table and my formula is fine. No error for inconsistent formula.

6 Replies

@JAnderson910 

It sounds like you are experiencing issues with your formula references when adding a new row using the Tab key in Excel. This might be related to how Excel handles formulas in tables. Here are a few suggestions to address this:

1. Use Table References:

If you are working with Excel tables (ListObjects), make sure your formula references are consistent with table references. When you use the Tab key to add a new row in a table, Excel automatically extends the formulas for the new row based on the pattern it detects in the existing formulas.

For example, if your formula is in cell A1:

=IF('Water Usage'!D28-'Water Usage'!$D27<0,0,'Water Usage'!D28-'Water Usage'!$D27)

and you're entering it in a table, Excel will likely extend it when a new row is added, creating something like:

=IF('Water Usage'!D29-'Water Usage'!$D28<0,0,'Water Usage'!D29-'Water Usage'!$D28)

If you want to ensure that your formulas are consistent, make sure to enter them directly in the table column where you want the formula and avoid using the Tab key to create new rows.

2. Adjust Table Formulas:

Check the formulas in your table columns and adjust them manually if needed. If Excel is not extending the formulas correctly, you might need to correct the references manually.

3. Use Structured References:

If you're working with Excel tables, consider using structured references for your formulas. For example:

=IF([@ColumnD] - INDEX('Water Usage'!$D$1:$D$100, ROW() - 1) < 0, 0, [@ColumnD] - INDEX('Water Usage'!$D$1:$D$100, ROW() - 1))

This way, the formula will adapt automatically when you add a new row in the table.

4. Turn Off Formulas Auto-Extend:

If the issue persists, you can try turning off the feature that automatically extends formulas in tables:

  1. Go to the "File" tab.
  2. Click on "Options."
  3. In the Excel Options dialog, go to the "Advanced" category.
  4. Scroll down to the "Editing options" section.
  5. Uncheck the "Extend data range formats and formulas" option.

Remember that turning off this feature might affect other aspects of your Excel experience, so use it carefully.

By using structured references and adjusting your table formulas, you can ensure that the formulas behave consistently when adding new rows. The text and steps were edited with the help of AI.

 

My answers are voluntary and without guarantee!

 

Hope this will help you.

Was the answer useful? Mark as best response and Like it!

This will help all forum participants.

@JAnderson910 I was unable to duplicate the described problem. Please clarify the following:

  1. Is the table located on the same sheet as the cells referenced in the formula ('Water Usage')? Or a different sheet?
  2. What is the address of the cell that contains the formula =IF('Water Usage'!D28-'Water Usage'!$D27<0, 0, 'Water Usage'!D28-'Water Usage'!$D27)?
  3. Is the formula consistent throughout the entire column?

 

It's possible the formula in the calculated column just needs to be "refreshed". Select any cell in the column that contains the correct formula, press F2 on your keyboard (or click into the formula bar), then press Enter. If the "AutoCorrect Options" icon autocorrect_options.png appears, click it and select "Overwrite all cells in this column with this formula".

 

Formula Tip:

 

=IF('Water Usage'!D29-'Water Usage'!$D28<0, 0, 'Water Usage'!D29-'Water Usage'!$D28)

 

...can be simplified using the MAX function:

 

=MAX('Water Usage'!D29-'Water Usage'!$D28, 0)

 

Everything for the formula is on a single sheet inside a table. The formula functions properly when I enter the new data on the row right below the table but if I use the TAB key to create a new entry the formula becomes inconsistent. This can get annoying since I can't use the TAB key when entering new lines I have to use the mouse to click on the row below my last entry.

 

JAnderson910_1-1701797798488.pngJAnderson910_2-1701797841292.png

Using the tab key to start a new row for entry. Formula skips the new row.

JAnderson910_3-1701797928682.png

Here I started a new row without using the tab by just entering data in the row below the table. here the formula stays consistent.

@JAnderson910 

best response confirmed by JAnderson910 (Copper Contributor)
Solution

@JAnderson910 The problem is definitely a result of the formula referencing cell D30, which is the next row located outside of the table. When a new table row is inserted by using the Tab key, the relative cell reference is affected in the same manner that inserting a new row in the middle of the table would result in inconsistent cell references. One way to solve this problem is to define a name in Name Manager using a relative row reference...

 

Start by selecting cell H29, for example. On the ribbon, go to Formulas > Define Name. Name it "NextMeterRead", then in the Refers To field, select cell D30, then press F4 on your keyboard twice to make it a relative row reference ($D30). It should look something like this:

 

Define Name: NextMeterReadDefine Name: NextMeterRead

 

Once defined, you can then update your calculated column formula as follows:

 

=IF(NextMeterRead-[@[Sump Meter]]>-1, NextMeterRead-[@[Sump Meter]], "")

 

Or, as mentioned in my previous reply, the MAX function could also do the trick:

 

=MAX(NextMeterRead-[@[Sump Meter]], 0)

 

NextMeterRead will always refer to the row below the current row, in Column D, regardless of how you go about inserting a new row. Cheers!

Thank you, it worked defining the name. Never have done that before and I changed the formula from IF to MAX. I still find it weird that the table could pick up the pattern of the formula when adding a new line by pressing the TAB key.
1 best response

Accepted Solutions
best response confirmed by JAnderson910 (Copper Contributor)
Solution

@JAnderson910 The problem is definitely a result of the formula referencing cell D30, which is the next row located outside of the table. When a new table row is inserted by using the Tab key, the relative cell reference is affected in the same manner that inserting a new row in the middle of the table would result in inconsistent cell references. One way to solve this problem is to define a name in Name Manager using a relative row reference...

 

Start by selecting cell H29, for example. On the ribbon, go to Formulas > Define Name. Name it "NextMeterRead", then in the Refers To field, select cell D30, then press F4 on your keyboard twice to make it a relative row reference ($D30). It should look something like this:

 

Define Name: NextMeterReadDefine Name: NextMeterRead

 

Once defined, you can then update your calculated column formula as follows:

 

=IF(NextMeterRead-[@[Sump Meter]]>-1, NextMeterRead-[@[Sump Meter]], "")

 

Or, as mentioned in my previous reply, the MAX function could also do the trick:

 

=MAX(NextMeterRead-[@[Sump Meter]], 0)

 

NextMeterRead will always refer to the row below the current row, in Column D, regardless of how you go about inserting a new row. Cheers!

View solution in original post