+ Reply to Thread
Results 1 to 5 of 5

Using countifs in VBA

  1. #1
    Forum Contributor
    Join Date
    09-19-2012
    Location
    NYC
    MS-Off Ver
    Excel 2010
    Posts
    137

    Using countifs in VBA

    Can someone please help me translate the following worksheet function for use in VBA?

    =COUNTIFS(sheet1!$B53:$B2031,"*x*",sheet1!$C53:$C2031,$A2,sheet1!$E$47:$E$2025,"final*")

    Thanks,

    Willardio

  2. #2
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Using countifs in VBA

    Something like this? Range("A1").Formula = "=COUNTIFS(sheet1!$B53:$B2031,""*x*"",sheet1!$C53:$C2031,$A2,sheet1!$E$47:$E$2025,""final*"")"

  3. #3
    Forum Contributor
    Join Date
    09-19-2012
    Location
    NYC
    MS-Off Ver
    Excel 2010
    Posts
    137

    Re: Using countifs in VBA

    Thanks JieJenn, but can I do it strictly using a VBA Worksheetfunction.Countifs code? I would like to translate the formula to work that way but can't seem to get the parameters straight without producing errors.

  4. #4
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Using countifs in VBA

    Here's an example

    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    10-01-2015
    Location
    Prague, Czech REpublic
    MS-Off Ver
    10
    Posts
    1

    Re: Using countifs in VBA

    I would like to add that if you like to countif only not empty cells in column A, the code would be:

    Sub test()
    Range("G2") = WorksheetFunction.CountIfs( _
    Range("A:A"), "<>" & vbNullString, Range("B:B"), "*Final*")
    End Sub


    Expressed like a formula in cell G3:

    =COUNTIFS(A:A;"<>"&"";B:B;"*Final*")


    DonJuanBlanco
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. COUNTIFS OR COUNTIFS needs to work
    By joshbellfi in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-23-2013, 10:55 AM
  2. Countifs = 0
    By Zagra147 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 05-22-2013, 10:59 AM
  3. CountIFs help!
    By Clark85 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-13-2013, 09:28 AM
  4. COUNTIFS OR...multiple countifs without duplication in the numbers
    By HooligaD in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-21-2012, 09:53 AM
  5. Replies: 0
    Last Post: 12-16-2011, 09:01 AM

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