Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre> Item | Total A | 16 B | 13 C | 9 </pre> <p>Assuming your above range is in A1:B5, my first formula is the following Array formula:</p> <pre><code>{=SUM(IF(ISERROR(FIND(B6,$A$1:$A$5)),0,$B$1:$B$5))} </code></pre> <p>You create an Array formula by entering the formula and holding down the <code>Ctrl+Shift</code> keys while you hit Enter. In my solution, I've created an area where I calculate by totals and have a column (called Item in this case) which indicates the letter I see in the original A column.</p> <p>If you were trying to enter this using VBA, you would use the <code>FormulaArray</code> property:</p> <pre><code>Selection.FormulaArray ="SUM(IF(ISERROR(FIND(B6,$A$1:$A$5)),0,$B$1:$B$5))" </code></pre> <p><strong>Update</strong></p> <p>Restricting the calculation to only visible cells is a bit more complicated. Suppose we have your original data in cells A1:B5. Let's also suppose our test values start in cell C7 (diagonal to the source data). Our totals formula would look like:</p> <pre><code>=SUMPRODUCT(SUBTOTAL(3,OFFSET($B$1:$B$5,ROW($B$1:$B$5)-ROW($B$1),0,1)), --NOT(ISERROR(FIND(C7,$A$1:$A$5))), $B$1:$B$5) </code></pre> <p>The following portion returns a range over the cells</p> <pre><code>OFFSET($B$1:$B$5,ROW($B$1:$B$5)-ROW($B$1),0,1) </code></pre> <p>This portion returns 1 for each visible cell and 0 for invisible cell</p> <pre><code>SUBTOTAL(3,OFFSET($B$1:$B$5,ROW($B$1:$B$5)-ROW($B$1),0,1)) </code></pre> <p>This portion is our criteria. <code>NOT(ISERROR(...</code> will return TRUE or FALSE. The double negative sign <code>--</code> converts that value into a negative integer and then removes that negation. </p> <pre><code>--NOT(ISERROR(FIND(C7,$A$1:$A$5))) </code></pre> <p>Lastly, the <code>SUMPRODUCT</code> function multiplies the matching arrays to each other and executes the sum. The first two arrays return a series of 0's or 1's. If the row is both visible and matches our criteria, then we get 1*1 multipled by the given value in the cell. If the given cell is not visible or does not match the criteria, one of the two return a zero and it zeroes out the entire item.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload