+ Reply to Thread
Results 1 to 2 of 2

Countif formula

Hybrid View

  1. #1
    Registered User
    Join Date
    05-21-2007
    Posts
    4

    Countif formula

    Hi all,

    I need help with a countif formula.

    Here's the deal, I have the following:

    A B C
    1 Miami Yes
    2 Atlanta Yes
    3 Miami NO
    4 Miami NO
    5 Atalanta NO

    I want to count how many times Miami and Yes are found in combination.

    Tx

  2. #2
    Registered User
    Join Date
    11-16-2006
    Posts
    80
    Try:

    Sub countMiami_Yes()
    
        Dim x As Integer
        Dim city As String
        Dim yesNo As String
        Dim countNum As Integer
        
        x = 1
        countNum = 0
        Cells(x, 1).Activate
        Do Until ActiveCell = ""
            city = Cells(x, 1).Value
            yesNo = Cells(x, 2).Value
            If city = "Miami" And yesNo = "Yes" Then
                countNum = countNum + 1
            End If
            x = x + 1
            Cells(x, 1).Activate
        Loop
        MsgBox ("Miami and Yes are found : " & countNum & " times")
    End Sub
    A message box will appear outlining how many time the combination appears!

    HTH,
    mccreaso

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1