subtotal函数
We looked at the Excel SUBTOTAL function on Friday, and saw how it works with hidden rows. The first argument tells Excel which function you want to use, such as SUM, MAX or AVERAGE. See how to make it easy for people to change Excel function with SUBTOTAL, to get a different result.
我们在星期五查看了Excel SUBTOTAL函数 ,并了解了它如何与隐藏行一起工作。 第一个参数告诉Excel您要使用哪个函数,例如SUM,MAX或AVERAGE。 了解如何使人们轻松使用SUBTOTAL更改Excel函数以获得不同的结果。
小计功能编号 (SUBTOTAL Function Numbers)
When you start typing the SUBTOTAL function, you'll see this list of function numbers. You can type one of the numbers, or double-click on an item in the drop down list.
当您开始输入SUBTOTAL函数时,您会看到此函数编号列表。 您可以键入数字之一,或双击下拉列表中的项目。
改变功能 (Change the Function)
Instead of typing the first argument in a SUBTOTAL formula, you could make it more flexible, by allowing users to select the function they want. In this example, we'll set up total formulas, and users can change the function at any time.
通过允许用户选择所需的函数,可以使它更灵活,而不是在SUBTOTAL公式中键入第一个参数。 在此示例中,我们将设置总计公式,用户可以随时更改函数。
设置命名Excel表 (Set Up the Named Excel Table)
In this example, there are sales orders, in an Excel table named SalesTable. We'll create totals for the Qty, Cost and Amt columns in that table.
在此示例中,在名为SalesTable的Excel表中有销售订单。 我们将在该表中为“数量”,“成本”和“金额”列创建总计。
列出小计功能 (List the SUBTOTAL Functions)
In the Excel Help files, if you search for SUBTOTAL, you'll find a table of the functions and their numbers. If you're using Excel 2003, or later version, you can use the 100 series number, which ignore both filtered and manually hidden values.
在Excel帮助文件中,如果搜索SUBTOTAL,则会找到函数及其编号的表。 如果您使用的是Excel 2003或更高版本,则可以使用100系列编号,该编号将同时忽略过滤后的值和手动隐藏的值。
Copy that table to a sheet in the Excel workbook, and delete any functions that you don't need.
将该表复制到Excel工作簿中的工作表,然后删除不需要的任何功能。
Then, name the list of numbers, as FuncNum.
Name the list of function names, as FuncList.
将函数名称列表命名为FuncList。
创建功能下拉列表 (Create a Drop Down List of Functions)
On the sales order sheet, above the Excel table, create a drop down list of functions, by using a data validation list.
在Excel表格上方的销售订单表上,使用数据验证列表创建功能下拉列表。
Name the cell with the drop down list, as FunctionSel.
使用下拉列表将单元命名为FunctionSel。
查找功能编号 (Find the Function Number)
On the worksheet with the lists, we'll use the INDEX function to determine which function number was selected.
在带有列表的工作表上,我们将使用INDEX函数来确定选择了哪个函数号。
In cell E3, enter this INDEX function, to find the selected function name, and return the matching function number:
在单元格E3中,输入此INDEX函数,以找到选定的函数名称,并返回匹配的函数号:
=INDEX(FuncNum, MATCH(FunctionSel,FuncList,0))
= INDEX(FuncNum,MATCH(FunctionSel,FuncList,0))
Name the function number cell as FuncNumSel.
将功能编号单元命名为FuncNumSel。
创建小计公式 (Create the Subtotal Formulas)
In cell E2 on the sales order sheet, enter a subtotal function that uses the selected function number as its first argument.
在销售订单表的单元格E2中,输入将所选功能编号用作其第一个参数的小计功能。
=SUBTOTAL(FuncNumSel,SalesTable[Qty])
= SUBTOTAL(FuncNumSel,SalesTable [Qty])
If you're not using an Excel table, you could use a cell reference as the second argument, instead of the table reference.
如果您不使用Excel表,则可以使用单元格引用作为第二个参数,而不是表引用。
Copy the formula across to G2, and format the numbers, if necessary.
将公式复制到G2,并在必要时格式化数字。
Then, select a function name from the drop down list in cell C2, and the total cells will automatically change, to show the subtotal for the selected function.
然后,从单元格C2的下拉列表中选择一个功能名称,总单元格将自动更改,以显示所选功能的小计。
下载样本文件 (Download the Sample File)
To see the SUBTOTAL function, and the lists, you can download the Flexible Subtotal Function sample file.
要查看SUBTOTAL功能和列表,可以下载Flexible Subtotal Function示例文件 。
The file is in Excel 2007 format, and is zipped. There are no macros in the workbook.
该文件为Excel 2007格式,并且已压缩。 工作簿中没有宏。
视频:使用SUBTOTAL更改Excel函数 (Video: Change Excel Function With SUBTOTAL)
To see the steps for creating the interactive summary Subtotal formulas, and the drop down list, watch this short video tutorial.
要查看创建交互式汇总小计公式的步骤以及下拉列表,请观看此简短视频教程。
翻译自: https://contexturesblog.com/archives/2011/03/14/change-excel-function-with-subtotal/
subtotal函数