在Excel中动态设置求和公式 [英] Dynamically setting the sum formula in excel

查看:75
本文介绍了在Excel中动态设置求和公式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想对两个单元格的值求和.就像我想要C1中A1和A2的总和一样,公式将是 = sum(A1,A2).但在此公式中行号是固定的(即1和2).但我希望该行号应在excel中动态确定.

I want to sum two cells values. Like i want sum of A1 and A2 in C1 then the formulla will be =sum(A1,A2). but in this formulla row number fixed (i.e. 1 and 2). but I want that row number should be decided dynamically in excel.

假设我在A1到A100的单元格区域中有整数值,现在我想要A1到A100之间的任何两个值之和.我将行号放在B1和B2中,并将此公式写在C1中

suppose i have integer values in cell range A1 to A100.Now i want sum of any two values beween A1 to A100. I am putting row number in B1 and B2 and writting this formula in C1

=SUM(A&B1,A&B2)

所以在上面的公式中,列A是固定的,我想从其他单元格中选择行号.

so in above formulla Column A is fixed and i want to pick row number from other cell.

例如,如果我在B1中输入5,在B2中输入10,则公式应将A5和A10值相加.同样,我可以在B1和B2列中输入介于1到100之间的任何值.

for example if i enter the 5 in B1 and 10 in B2 the formulla should sum the A5 and A10 values. Similarly i can enter any value between 1- 100 in column B1 and B2.

我想直接在excel中而不是在宏中进行.

I want to do it directly in excel not in macro.

推荐答案

使用 INDIRECT 输入B1和B2作为A的变量,即

use INDIRECT to enter the B1 and B2 as variables for A, ie

=SUM(INDIRECT("A"&B1&":A"&B2))

添加A5和A10(而不是SUM A5:A10

to add A5 and A10 (rather than SUM A5:A10

=INDIRECT("A"&B1)+INDIRECT("A"&B2)

这篇关于在Excel中动态设置求和公式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆