Excel:SUMIF引用动态范围

时间:2018-09-21 14:55:16

标签: excel-formula excel-2010

我需要参考动态列编写一个SUMIF公式。

这里是一个例子。

在单元格G7中,我需要从单元格D3中存储的列(在这种情况下为H)到在单元格D4中存储的列(在这种情况下)与Mark(第3行)相关的数字之和L)。该公式的结果给出了单元格G7中的数字7和G8中的数字8。

我希望在不使用VBA的情况下解决此问题。

我想到了类似的东西

G7 = =SUMIF(F:F;F7;<the value stored in D3>:<the value stored in D4>)

我希望已经很好地解释了这个问题。

enter image description here

1 个答案:

答案 0 :(得分:1)

一个简单的总和为两个INDEX / MATCH即可:

export class FilterPage implements OnInit, OnDestroy {

  private filterItems: string[];

  constructor() { }

  ngOnInit() {
    if (localStorage.getItem('filterItems'))
      this.filterItems = JSON.parse(localStorage.getItem('filterItems'));
    } else {
      this.filterItems = [];
    }
  }
  
  ngOnDestroy() {
    if(this.filterItems.length > 0) {
      localStorage.setItem('filterItems', JSON.stringify(this.filterItems));
    }
  }
  
  addFilterItem(item: string) {
    if (!this.filterItems.includes(item)) {
      this.filterItems = [...this.filterItems, item];
    }
  }
  
  removeFilterItem(item: string) {
    if (this.filterItems.includes(item)) {
      this.filterItems = this.fiterItems.filter(currentItem => currentItem !== item);
    }
  }
}

请注意,这仅适用于Z列,如果您的数据已过期,我们将需要找到与=SUM(INDEX($1:$10000,MATCH(F7,F:F,0),CODE(UPPER($D$3))-64):INDEX($1:$4,MATCH(F7,F:F,0),CODE(UPPER($D$4))-64)) 不同的内容来表示列范围。

我们需要使用INDIRECT,如果可以避免,应该使用。应避免使用它,因为它易挥发。因此,如果您的数据经过Z列,则使用:

CODE(UPPER($D$3))-64

enter image description here

相关问题