Or another alternative

=SUMPRODUCT((Sheet1!$A$2:$A$2270=A2)*((Sheet1!$B$2:$B$2270=12)+(Sheet1!$B$2:$B$2270=13)))

Sub cnt()
Dim rng As Range
Dim rng1 As Range
Dim i As Integer
Set rng = Sheet1.Range("A2:A" & Sheet1.Range("A" &
Rows.Count).End(xlUp).Row)
Set rng1 = Sheet1.Range("B2:B" & Sheet1.Range("B" &
Rows.Count).End(xlUp).Row)
For i = 2 To Sheet2.Range("A" & Rows.Count).End(xlUp).Row
Sheet2.Cells(i, 2).Value = Evaluate("=SUMPRODUCT((" & rng.Address(, , ,
True) & "=A" & i & ")*((" & rng1.Address(, , , True) & "=12)+(" &
rng1.Address(, , , True) & "=13)))")
Next
End Sub

Regards,
Sam Mathai CHacko

On Thu, Sep 13, 2012 at 12:15 AM, Paul Schreiner <schreiner_p...@att.net>wrote:

> I believe that the problem is that, when you enter the formula in the
> Workbook,
> you're entering it as an "ARRAY" formula, where it matches the value in
> Column A
> and column B is EITHER 12 or 13 ({12,13})
>
> But in your VBA, you're only counting a match of 12:
>
> Sheet2.Cells(i, 2) = WorksheetFunction.CountIfs(rng, Cells(i, 1), rng1,
> "12")
>
> I don't believe that the VBA WorksheetFunction is going to allow you to
> enter an array function.
> I think you're going to have to add them like:
>
> Sheet2.Cells(i, 2) = WorksheetFunction.CountIfs(rng, Cells(i, 1), rng1,
> "12") _
>                            + WorksheetFunction.CountIfs(rng, Cells(i, 1),
> rng1, "13")
>
> I changed the VBA and result matches column "C".
>
>
> *Paul*
>
> -----------------------------------------
> *“Do all the good you can,
> By all the means you can,
> In all the ways you can,
> In all the places you can,
> At all the times you can,
> To all the people you can,
> As long as ever you can.” - John Wesley
> *-----------------------------------------
>
>
>  ------------------------------
> *From:* jeet singh <jeetexcelt...@gmail.com>
> *To:* excel-macros@googlegroups.com
> *Sent:* Wed, September 12, 2012 2:32:12 PM
> *Subject:* $$Excel-Macros$$ Count multiple criteria in a column with the
> help of VBA
>
> Dear all,
>
> I want to count multiple criteria in a column. I have done this query in
> excel, Formula have given below.
>
> =SUM(COUNTIFS(Sheet1!C:C,Sheet2!A2,Sheet1!E:E,{12,13}))
>
> Regards
>
>
> --
> Join official facebook page of this forum @
> https://www.facebook.com/discussexcel
>
> FORUM RULES (1120+ members already BANNED for violation)
>
> 1) Use concise, accurate thread titles. Poor thread titles, like Please
> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
> will not get quick attention or may not be answered.
>
> 2) Don't post a question in the thread of another member.
>
> 3) Don't post questions regarding breaking or bypassing any security
> measure.
>
> 4) Acknowledge the responses you receive, good or bad.
>
> 5) Cross-promotion of, or links to, forums competitive to this forum in
> signatures are prohibited.
>
> 6) Jobs posting is not allowed.
>
> 7) Sharing copyrighted ebooks/pirated ebooks/their links is not allowed.
>
> NOTE : Don't ever post personal or confidential data in a workbook. Forum
> owners and members are not responsible for any loss.
> ---
> You received this message because you are subscribed to the Google Groups
> "MS EXCEL AND VBA MACROS" group.
> To post to this group, send email to excel-macros@googlegroups.com.
> To unsubscribe from this group, send email to
> excel-macros+unsubscr...@googlegroups.com.
>
>
>
> --
> Join official facebook page of this forum @
> https://www.facebook.com/discussexcel
>
> FORUM RULES (1120+ members already BANNED for violation)
>
> 1) Use concise, accurate thread titles. Poor thread titles, like Please
> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
> will not get quick attention or may not be answered.
>
> 2) Don't post a question in the thread of another member.
>
> 3) Don't post questions regarding breaking or bypassing any security
> measure.
>
> 4) Acknowledge the responses you receive, good or bad.
>
> 5) Cross-promotion of, or links to, forums competitive to this forum in
> signatures are prohibited.
>
> 6) Jobs posting is not allowed.
>
> 7) Sharing copyrighted ebooks/pirated ebooks/their links is not allowed.
>
> NOTE : Don't ever post personal or confidential data in a workbook. Forum
> owners and members are not responsible for any loss.
> ---
> You received this message because you are subscribed to the Google Groups
> "MS EXCEL AND VBA MACROS" group.
> To post to this group, send email to excel-macros@googlegroups.com.
> To unsubscribe from this group, send email to
> excel-macros+unsubscr...@googlegroups.com.
>
>
>



-- 
Sam Mathai Chacko

-- 
Join official facebook page of this forum @ 
https://www.facebook.com/discussexcel

FORUM RULES (1120+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 

6) Jobs posting is not allowed.

7) Sharing copyrighted ebooks/pirated ebooks/their links is not allowed.

NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To post to this group, send email to excel-macros@googlegroups.com.
To unsubscribe from this group, send email to 
excel-macros+unsubscr...@googlegroups.com.


Reply via email to