【发布时间】:2014-08-29 20:42:27
【问题描述】:
简介:
我有一个 Excel 工作簿,用于跟踪游戏《炉石传说》的统计数据。一张表包含每个单独游戏的数据(输赢等)。另一张表允许用户根据用户输入的搜索条件搜索赢/输统计信息。
我的问题:
在搜索表中,我使用的是 COUNTIFS 公式。这些公式变得相当长。有什么方法可以简化 COUNTIFS 公式?
设置:Excel 搜索表的外观:
| Column K | Column L |
|____________________|______________________________|
Row 5 |Date Start | User input goes in Column L |
Row 6 |Date End | |
Row 7 |Player's Class | |
... |Turn Number | |
|Deck Name | |
|Opponent's Class | |
|Opponent's Username | |
|Match Type 1 | |
|Match Type 2 | |
|Match Type 3 | |
|Match Type 4 | |
... |Match Type 5 | |
Row 17 |Match Type 6 | |
|____________________|______________________________|
| Column K | Column L |
|______________________|_______________________________________________|
Row 21 | Total Matches Played | Data is displayed based on the user's input. |
Row 22 | Total Wins | The code that needs simplifying is goes here. |
Row 23 | Total Losses | |
Row 24 | Win to Loss Ratio | |
Row 25 | Win Percentage | |
Row 26 | Loss Percentage | |
|______________________|_______________________________________________|
需要简化的代码。此代码位于 第 22 行 L 列:
=(COUNTIFS('Indiv. Match Stats'!I:I,"Win",'Indiv. Match Stats'!H:H,L12,
'Indiv. Match Stats'!L:L,L7,'Indiv. Match Stats'!T:T,L9,'Indiv. Match
Stats'!Q:Q,L10,'Indiv. Match Stats'!P:P,L11,'Indiv. Match Stats'!C:C,
">="&L5,'Indiv. Match Stats'!C:C,"<="&L6,'Indiv. Match Stats'!N:N,L8))
+
(COUNTIFS('Indiv. Match Stats'!I:I,"Win",'Indiv. Match Stats'!H:H,L13,
'Indiv. Match Stats'!L:L,L7,'Indiv. Match Stats'!T:T,L9,'Indiv. Match
Stats'!Q:Q,L10,'Indiv. Match Stats'!P:P,L11,'Indiv. Match Stats'!C:C,
">="&L5,'Indiv. Match Stats'!C:C,"<="&L6,'Indiv. Match Stats'!N:N,L8))
+
(The code repeats the above four more times. Basically each block of code
stands for one Match Type in Column K)
工作表和代码说明:
用户在第 5 行到第 17 行的 L 列中输入条件。任何留空的内容都被视为通配符。用户输入条件缩小了搜索结果的范围,并确定了在第 21 行到第 26 行的 L 列中显示的数据。
上面显示的代码多次引用名为Indiv. Match Stats 的单独工作表。 COUNTIFS 按日期、玩家等级、回合数、套牌名称……和比赛类型缩小搜索范围。不幸的是,所有这些标准都必须重复,对每种匹配类型重复一次,然后代码添加结果,给出最终结果(给定标准的适当的赢、输等数量)。它是一大块代码,正在被添加到另一个代码块中。
有没有更好的方法来做到这一点,或者只是以某种方式在视觉上简化代码?有没有办法让相似的代码块等于某个变量,这样就不必重复输入这些相似的部分?
【问题讨论】:
标签: excel excel-formula excel-2010