+ Reply to Thread
Results 1 to 3 of 3

Why do I get countif blanks ?

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    10-25-2012
    Location
    Honolulu, Hawaii
    MS-Off Ver
    Excel 2013
    Posts
    128

    Why do I get countif blanks ?

    Hello,

    I am trying to make the following code work correctly but all I get is get a blank. Truthfully, I would like to make an array out of this but I am stumped.

    Kindest regards to all those that help. Sample file is attached.

    Sub ITest()
    
    Dim ws As Worksheet
    Dim Val As Variant 'Double
    Dim LD As Long  '*
    
    
    Application.ScreenUpdating = False
    
    For Each ws In ActiveWorkbook.Worksheets
       With ws
     LD = .Range("A" & Rows.Count).End(xlUp).Row
        
    Val = Application.WorksheetFunction.CountIfs(.Range("I:I"), "=100", Range("I:I"), "=200", Range("I:I"), "=300", Range("I:I"), "=400")
        
        Range("K2:K" & LD).FillDown
        'Range("K10").Value = Val
        
         End With
    Next ws
    
    Application.ScreenUpdating = True
    
    End Sub
    Aloha
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,937

    Re: Why do I get countif blanks ?

    COUNTIFS:
    Each cell in a range is counted only if all of the corresponding criteria specified are true for that cell.

    You have four criteria which must be simultaneously true which is impossible for the data/criteria.
    Ben Van Johnson

  3. #3
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: Why do I get countif blanks ?

    Hi rmccain,

    Try this:

    Option Explicit
    Sub Macro1()
    
        Dim ws  As Worksheet
        Dim Val As Double
        Dim LD  As Long
        
        Application.ScreenUpdating = False
        
            For Each ws In ActiveWorkbook.Worksheets
                With ws
                    LD = .Range("A" & Rows.Count).End(xlUp).Row
                    Val = Evaluate("COUNTIFS('" & ws.Name & "'!I:I,"">=100"",'" & ws.Name & "'!I:I,""<=400"")")
                    .Range("K2:K" & LD).Value = Val
                End With
            Next ws
            
        Application.ScreenUpdating = True
    
    End Sub
    Regards,

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

+ 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. [SOLVED] Countif averages no blanks
    By psjpsjpsjpsj in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-08-2016, 04:52 AM
  2. Countif function counts blanks
    By ckenn134 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-27-2013, 03:31 PM
  3. If and Countif treat blanks differently?
    By studiosa in forum Excel General
    Replies: 4
    Last Post: 02-28-2012, 10:00 PM
  4. Ignore blanks when using COUNTIF
    By mattmac in forum Excel General
    Replies: 3
    Last Post: 05-27-2011, 04:56 AM
  5. SUMIF & COUNTIF and omitting blanks
    By stacks in forum Excel General
    Replies: 4
    Last Post: 06-29-2010, 10:11 AM
  6. Ignore blanks using =SUMIF/COUNTIF
    By Casper9T9 in forum Excel General
    Replies: 10
    Last Post: 06-05-2009, 05:26 PM
  7. COUNTIF sees blanks
    By savarin in forum Excel General
    Replies: 4
    Last Post: 11-04-2007, 05:04 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