简体   繁体   English

拖动Excel公式以增加跨列的行

[英]Dragging excel formula to increment rows across columns

I want to count the amount of equal values between two distinct sets. 我想计算两个不同集合之间相等值的数量。

For example, the first set is composed of 15 distinct values, as figure below shows: 例如,第一组由15个不同的值组成,如下图所示:

设置比较

Next, I have another set, for example, line 1 in the next figure (set 1621), with another 15 distinct values. 接下来,我有另一个集合,例如,下图中的行1(集合1621),还有另外15个不同的值。 The problem is that I want to calculate the amount of values that are equal in both sets. 问题是我想计算两个集合中相等的值量。

The problem is very similar to checking the result of a lottery ticket. 问题与检查彩票结果非常相似。

套套

There are several "sets" to compare to the initial set (for example, in the figure above we have sets 1621, 1620, and so on). 有几个“集合”可以与初始集合进行比较(例如,在上图中,我们有集合1621、1620,依此类推)。 Each set appears in a next row in the spreadsheet. 每一组都显示在电子表格的下一行中。

However, the expected presentation is as follows: the amount of equal values between each comparison should be presented in distinct columns, as figure below shows: 但是,预期的呈现方式如下:每个比较之间的相等值的数量应在不同的列中呈现,如下图所示:

预期结果

If we used a formula, in R2, S2, T2 like 如果我们使用公式,在R2,S2,T2中

=SUMPRODUCT(COUNTIF($B$2:$P$2;Sheet2!B1:P1))
=SUMPRODUCT(COUNTIF($B$2:$P$2;Sheet2!B2:P2))
=SUMPRODUCT(COUNTIF($B$2:$P$2;Sheet2!B3:P3))

It could work fine, and the results would show up. 它可以正常工作,结果将显示出来。 However, instead of manually typing such functions into each individual cell, as this would be very time-consuming, I would like to have a solution to increment the rows across columns. 但是,不是要在每个单独的单元格中手动键入此类函数,因为这将非常耗时,所以我想提供一种解决方案,以增加跨列的行。

Put this in the first cell and copy accross: 将其放在第一个单元格中并复制:

=SUMPRODUCT(COUNTIF(INDEX(Sheet2!$B:$P,COLUMN(A:A),0);$B$2:$P$2))

As it is dragged accross the COLUMN(A:A) will iterate and first return 1 then 2 then 3 the ... indicating the row to return. 当它拖动到整个COLUMN(A:A)时,它将进行迭代,首先返回1,然后返回2,然后返回3,表示返回的行。

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

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