[英]Copy formula across columns
I have a spreadsheet with 4 columns : A, B, C, D. 我有一个包含4列的电子表格:A,B,C,D。
I want to calculate the difference between AB and CD. 我想计算AB和CD之间的差异。 So in cell E2 I enter the formula =A2-B2 , and get the result that I want, which is the difference between AB.
因此,在单元格E2中,我输入公式= A2-B2,并得到我想要的结果,这是AB之间的差异。
Now I drag the formula in E2 to cell F2, expecting that Excel will "think" that now I want the difference between CD. 现在,我将E2中的公式拖动到单元格F2中,期望Excel将“思考”现在我想要CD之间的区别。 However, when I drag the formula from column E to column FI get =B2-C2 (you see, Excel assumes I want to use B2 again).
但是,当我将公式从E列拖动到FI列时,得到= B2-C2(您会看到,Excel假定我想再次使用B2)。
My question is: how can I make Excel “understand” that I want to use =C2-D2 after =A2-B2, and NOT =B2-C2? 我的问题是:如何使Excel“了解”要在= A2-B2和NOT = B2-C2之后使用= C2-D2?
This an abbreviated example. 这是一个简短的示例。 The original data-set has hundred of columns.
原始数据集有数百列。 Thanks for your help.
谢谢你的帮助。
There's no way in the UI that you get Excel to "think" that much - it'll only shift the references by one column if you drag it across. 在用户界面中,您无法使Excel进行太多“思考”-如果将引用拖到另一列,则只能将引用移动一列。 If deleting the columns in between is not an option, you need to rewrite you formula, eg:
如果不能删除中间的列,则需要重写公式,例如:
=OFFSET(A1,0,COLUMN(L1)-COLUMN($L1))-OFFSET(B1,0,COLUMN(L1)-COLUMN($L1))
In this example, it is assumed that you start showing the difference in column L - of course you need to adjust according to your worksheet - but once done, you can drag the formula to the right as far as you need. 在此示例中,假定您开始显示L列中的差异-当然您需要根据工作表进行调整-但是完成后,您可以根据需要将公式向右拖动。
As your original data-set has hundreds of columns, you may want to use a non-volatile formula, eg: 由于原始数据集有数百列,因此您可能需要使用非易失性公式,例如:
=INDEX(A1:K1,1+COLUMN(L1)-COLUMN($L1))-INDEX(A1:K1,2+COLUMN(L1)-COLUMN($L1))
This will speed up calculations in the workbook. 这将加快工作簿中的计算。 Depending on how big the data-set is and how many other formulas are in the workbook, the difference in speed could be enormous.
根据数据集的大小以及工作簿中还有多少其他公式,速度差异可能很大。
The same conditions apply as in Peter's example. 同样的条件适用于彼得的例子。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.