+ Reply to Thread
Results 1 to 3 of 3

CountIF formula in VBA

  1. #1
    Registered User
    Join Date
    09-10-2013
    Location
    Spain
    MS-Off Ver
    Excel 2010
    Posts
    57

    CountIF formula in VBA

    Hello,
    Does anyone know how to write these two formulas in VBA code?

    =COUNTIF(Z2:Z77,"<21")
    and
    =COUNTIFS(F2:F92,">=21",F2:F92,"<+30")

    Here is the catch though - The range will not always be Z2:Z77 or F2:F92. The code will always start with Z2 and F2 and then autofill to the bottom.

    Thank you!

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: CountIF formula in VBA

    Gives you a good start

    Please Login or Register  to view this content.

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: CountIF formula in VBA

    If you reference the entire column, the Countif function knows to only count within the used range of the worksheet. There is no efficiency gain in referencing the specific range of all the column data versus the entire column.

    Please Login or Register  to view this content.
    Last edited by AlphaFrog; 10-23-2013 at 02:23 PM.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

+ 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. CountIf formula results in the formula itself being displayed.
    By NewKid in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 07-19-2017, 03:31 PM
  2. [SOLVED] Using Countif formula on cells that have a Left formula
    By fsoares22 in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 07-10-2013, 11:13 AM
  3. [SOLVED] =Subtotal(countif,Range); Subtotal and countif in 1 formula [SOLVED]
    By thomas.mapua in forum Excel General
    Replies: 5
    Last Post: 01-06-2012, 11:33 AM
  4. Adding a CountIF to a formula that is already Countif
    By Cmorgan in forum Excel General
    Replies: 4
    Last Post: 06-01-2011, 09:34 AM
  5. #value! for the formula countif
    By chinsian.chen in forum Excel General
    Replies: 5
    Last Post: 05-27-2009, 05:50 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