简体   繁体   English

总和命名范围由几列和几行组成

[英]Sum named range consists of several columns and rows

I have a list that is divided into countries vertical and years horizontal like below.我有一个列表,分为垂直国家和水平年份,如下所示。

I need to sum all numbers for 2020 respective for each country.我需要总结每个国家 2020 年的所有数字。 Each country have several lines divided into different months.每个国家/地区都有几条线路,分为不同的月份。

             2020                     2021
         J | F | M | A | M |...| J | F | M | A | M |...
-------------------------------------------------------
Denmark |  |   | 15|   | 12|   |   |   |   |   |   |
Norway  |  |   |   |   |   |   |   |   | 10|   |   |
Germany |  |   |   | 11|   |   |   |   |   |   |   |

Each year have been called a named range, eg Year2020 .每一年都被称为一个命名范围,例如Year2020 I have tried using =SUMPRODUCT(SUMIFS(Year2020;CountryRNG;Country)) , MATCH/INDEX and also =SUM(INDEX(Year2020;0;MATCH(1E+99;INDEX(Year2020;1;0)))) .我曾尝试使用=SUMPRODUCT(SUMIFS(Year2020;CountryRNG;Country))MATCH/INDEX=SUM(INDEX(Year2020;0;MATCH(1E+99;INDEX(Year2020;1;0))))

How can I do this with one formula?我怎样才能用一个公式做到这一点?

You can use SUMPRODUCT:您可以使用 SUMPRODUCT:

=SUMPRODUCT((Country=CountryRNG)*Year2020)

With a few notes:有几个注意事项:

  • CountryRNG and Year2020 have the same number of rows CountryRNG 和 Year2020 的行数相同
  • Year2020 is only the data. Year2020 只是数据。 No Text or Errors in the data field数据字段中没有文本或错误
  • Both ranges are limited to the data and does not include full column references.这两个范围都仅限于数据,不包括完整的列引用。 This is to limit the number of iterations that will slow down the calcs.这是为了限制会减慢计算速度的迭代次数。 It will work with extra rows, but the more unneeded iteration will cause extra work.它将处理额外的行,但更多不需要的迭代将导致额外的工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM