multicondition summing/counting using cell references

benhmckelvey

New Member
Joined
Oct 22, 2008
Messages
7
I would like to COUNT (could be SUM) the number of instances where column A = $D$1 while column B = $E$1. So going by the table below the answer should be 3. I found I can do it when I insert "D-2" into a SUMPRODUCT formula but not when I refer to cell $D$1. If I can help it I would like to refrain from using a helper column. Any ideas guys? Cheers Ben

<table style="border-collapse: collapse; width: 269pt;" width="358" border="0" cellpadding="0" cellspacing="0"><col style="width: 29pt;" width="38"> <col style="width: 48pt;" span="5" width="64"> <tbody><tr style="height: 15pt;" height="20"> <td class="xl67" style="height: 15pt; width: 29pt;" width="38" height="20">
</td> <td class="xl68" style="width: 48pt;" width="64">A</td> <td class="xl68" style="width: 48pt;" width="64">B</td> <td class="xl68" style="width: 48pt;" width="64">C</td> <td class="xl68" style="width: 48pt;" width="64">D</td> <td class="xl68" style="width: 48pt;" width="64">E</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl69" style="height: 15pt;" height="20">1</td> <td>D-2</td> <td class="xl66">D-2</td> <td>
</td> <td>D-2</td> <td>D-3</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl69" style="height: 15pt;" height="20">2</td> <td>D-2</td> <td class="xl66">D-3</td> <td>
</td> <td>
</td> <td>
</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl69" style="height: 15pt;" height="20">3</td> <td>D-2</td> <td class="xl66">D-4</td> <td>
</td> <td>
</td> <td>
</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl69" style="height: 15pt;" height="20">4</td> <td>D-2</td> <td class="xl66">D-3</td> <td>
</td> <td>
</td> <td>
</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl69" style="height: 15pt;" height="20">5</td> <td>D-2</td> <td class="xl66">D-4</td> <td>
</td> <td>
</td> <td>
</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl69" style="height: 15pt;" height="20">6</td> <td>D-2</td> <td class="xl66">D-3</td> <td>
</td> <td>
</td> <td>
</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl69" style="height: 15pt;" height="20">7</td> <td class="xl66">D-3</td> <td class="xl66">D-4</td> <td>
</td> <td>
</td> <td>
</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl69" style="height: 15pt;" height="20">8</td> <td class="xl66">D-3</td> <td class="xl66">D-3</td> <td>
</td> <td>
</td> <td>
</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl69" style="height: 15pt;" height="20">9</td> <td class="xl66">D-3</td> <td class="xl66">D-2</td> <td>
</td> <td>
</td> <td>
</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl69" style="height: 15pt;" height="20">10</td> <td class="xl66">D-3</td> <td class="xl66">D-2</td> <td>
</td> <td>
</td> <td>
</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl69" style="height: 15pt;" height="20">11</td> <td class="xl66">D-3</td> <td class="xl66">D-4</td> <td>
</td> <td>
</td> <td>
</td> </tr> </tbody></table>
 

AdamL

Well-known Member
Joined
Sep 25, 2008
Messages
767
You might want to post the formula you tried Ben, because I can't see why

=SUMPRODUCT(--($A$1:$A$11=$D$1),--($B$1:$B$11=$E$11))

wouldn't work.
 

benhmckelvey

New Member
Joined
Oct 22, 2008
Messages
7
Thanks Adam

The 2 formulas I was using was

=SUMPRODUCT(($A:$A=$D$1)*($B:$B=$E$1))
and
{=SUM(($A:$A=$D$1)*($B:$B=$E$1))}

Where the 2nd formula would work but it was hard-coated in.

I haven't used the double negative before but it works a treat
 

AdamL

Well-known Member
Joined
Sep 25, 2008
Messages
767
No problem Ben.

I just wonder if you're using pre-Excel 2007, in which case whole columns do not work with SUMPRODUCT (I think).

Cheers
Adam
 

PaddyD

MrExcel MVP
Joined
May 1, 2002
Messages
14,234
"...(I think)..."

You are correct. Best to only calculate over the data that's actually being used.
 

Forum statistics

Threads
1,081,447
Messages
5,358,731
Members
400,509
Latest member
excellearner241

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top