Count in a range how many meet two conditions across a row, VBA

Technowolf

Board Regular
Joined
Aug 28, 2014
Messages
181
Okay, I don't think this is that hard but I'm not sure exactly how to do it.
I want it to count how many times something meets two conditions across a row. For example, I want to know how many times A is 1F and B is 20, but only if they're on the same row together (as in, don't count 1D & 20 or 1F & 10, etc). I want it to check how many times that happens for the whole set of data. And show the results in cell C1.

ABC
1F20
1D20
1F10
1D20
1F20
1F10
1D20
1D10
1D20
1F20

<tbody>
</tbody>

Suggestions?
 
Last edited:

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Okay, yeah that I started with a countifs but didn't know if it would pair rows. I can work with that. Okay, followup question.
(because I need to use this in a macro)
How do I make a formula work with quotes in a macro?

Code:
Range("C2").Formula = "[COLOR=#333333]COUNTIFS(A:A,"1F",B:B,20)[/COLOR]"

But the "s around the "1F" screw up the macro. How do I make that work?
 
Upvote 0
Ahhh I figured it out. Have to double "".

Code:
[COLOR=#333333]Range("C2").Formula = "[/COLOR][COLOR=#333333][COLOR=#333333]COUNTIFS(A:A,""1F"",B:B,20)[/COLOR][/COLOR][COLOR=#333333]"[/COLOR]
 
Upvote 0

Forum statistics

Threads
1,214,553
Messages
6,120,182
Members
448,948
Latest member
spamiki

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top