How do I copy a cell formula by reference (or eval

2020-05-01 03:48发布

Data: a set of cells B2:B9 with numbers.

Result: kept in C2:C9, where I apply some formula to the relative cell on the left (e.g. C2 depends on B2, C3 depends on B3, etc.).

The formula can be, for example:

C2: = B2+1

or

C2: = B2*B2

Normally, I'll define a formula in C2, and copy it to C3:C9. But any change to the formula would require copying it again.

I'd like to keep the formula in a cell, say C1, and use it in C2:C9. The obvious solution is to define a VBA function. But I don't want to use VBA (if there was a builtin python, then maybe). Instead, I have the simple excel cell formula, and it's convenient.

There's the evaluate function, but I can't supply a parameter, such as the relative cell.

标签: excel
1条回答
Anthone
2楼-- · 2020-05-01 04:43

You can use a table. This will automatically update the column with the formula.

Select your data range, and press CTRL+T (or Insert -> Table).

Then, enter your formula in the top cell and you'll see the others follow suit.

enter image description here

Edit: Also, note that if you add new rows to the table, they'll automatically get updated with any formulas too. So there's no need to have "extra" empty rows to keep the formulas there in case new data is added. This is automatically done by the Table.

查看更多
登录 后发表回答