Interesting "trick" to get around a table problem

JenniferMurphy

Well-known Member
Joined
Jul 23, 2011
Messages
2,676
Office Version
  1. 365
Platform
  1. Windows
I came across a problem I often have with tables, or maybe it's the way I use tables. I often want to start a table with a constant and then perform some calculation, like adding 1, in each subsequent row, like this:

1721012159757.png


If I create the table with the constants in Row 1, then add the expressions in Row 2, they work, but they do not propagate. I have to manually drag the expressions down.

Medical Logs.xlsx
FG
3DateNumber
46/01/241
56/02/242
66/03/243
7
8
Sheet2
Cell Formulas
RangeFormula
F5:G6F5=F4+1


I just discovered a trick that gets around this. It I create the first 2 rows before converting it to a table, it works. Here it as a range:

Medical Logs.xlsx
CD
3DateNumber
46/01/241
56/02/242
Sheet2
Cell Formulas
RangeFormula
C5:D5C5=C4+1


Here it is after converting it to a table:

Medical Logs.xlsx
CD
3DateNumber
46/01/241
56/02/242
Sheet2
Cell Formulas
RangeFormula
C5:D5C5=C4+1


And here it is after I just tabbed to 3 new rows. They propagated automatically. 🤔🤨🤔😯

Medical Logs.xlsx
CD
3DateNumber
46/01/241
56/02/242
66/03/243
76/04/244
86/05/245
Sheet2
Cell Formulas
RangeFormula
C5:D8C5=C4+1


Any explanation why one works and the other doesn't?
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
An excel table tries to work out what formula to use as the default for the rows.
By entering the constant first you are telling it that the default for the row is a constant.
Simply enter the formula first (even if it errors out) then overwrite the formula in row 1 and enter your constant.

If you have already set it up the other way around, just copy the the formula to all rows in the table then overwrite the formula in row 1 with the constant.

Having said that its not exactly best practice. Have you considered using something like the below so that you have the same formula in all rows.

20240715 Table ListObject Incrementing a value in a row JenniferMurphy.xlsx
BC
4DateNumber
51-Jun-241
62-Jun-242
73-Jun-243
84-Jun-244
95-Jun-245
Test
Cell Formulas
RangeFormula
B5:B9B5=DATE(2024,6,0)+ROW()-ROW(Table1[[#Headers],[Date]])
C5:C9C5=ROW()-ROW(Table1[[#Headers],[Number]])
 
Upvote 0
Solution
An excel table tries to work out what formula to use as the default for the rows.
IMHO, it could do a much better job of that. But that would require a better design.

Simply enter the formula first (even if it errors out) then overwrite the formula in row 1 and enter your constant.
Now that's a brilliant solution that is probably obvious to everyone else. 😢

If you have already set it up the other way around, just copy the the formula to all rows in the table then overwrite the formula in row 1 with the constant.
Another great suggestion.

Having said that its not exactly best practice. Have you considered using something like the below so that you have the same formula in all rows.
Nope, but I'll study it.

Thanks

PS: Re tables, I have so many suggestions. One is multiple totals rows. That one comes up all the time. Another is starter or helper rows above the table. That would solve this problem and a lot of others.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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