How Use COUNTIF to Count Non Empty Cells in Excel

Dossfm0q

Banned User
Joined
Mar 9, 2009
Messages
570
Office Version
  1. 2019
Platform
  1. Windows
How to Use COUNTIF to Count Non Empty Cells in Excel

Code:
Sub CountNonBlank()


    Cells.Clear
    Range("A1:A7") = Application.Transpose(Array("A", "B", "C", "D", "E", "", ""))
    
    Range("A10").Formula = "[COLOR=#ff0000][B]=COUNTIF(A1:A7,""<>"""""")[/B][/COLOR]" ' [COLOR=#ff0000]Rong result[/COLOR]
    
    Range("A12").Formula = "=[COLOR=#006400][B]ROWS(A1:A7) * COLUMNS(A1:A7)-COUNTBLANK(A1:A7)[/B][/COLOR]" ' [B][COLOR=#008000]Wright result[/COLOR][/B]
            '''''''''''''''''''''''''''''''''''''''''
            With Range("B10")
            .Value = "O"
            .Font.Name = "Wingdings 2"
            End With
            With Range("B12")
            .Value = "P"
            .Font.Name = "Wingdings 2"
            End With
            ''''''''''''''''''''''''''''''''''''''
End Sub
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Yes Sir I did

Code:
Public Sub CountNonEmptyCell()




    Cells.Clear
    [A1] = "A,BB,CCC,DDDD,EEEEE,FFFFFF"
    
    Range("A3:A12").FormulaArray = "=IFERROR(MID(A$1,FIND(""|"",SUBSTITUTE("",""&A$1&"","","","",""|"",(ROW()-ROW(B$3)+1))),FIND("","",A$1&"","",FIND(""|"",SUBSTITUTE("",""&A$1&"","","","",""|"",(ROW()-ROW(B$3)+1))))-FIND(""|"",SUBSTITUTE("",""&A$1&"","","","",""|"",(ROW()-ROW(B$3)+1)))),"""")"


   [COLOR=#ff0000][B] [A13] = "=COUNTA(A3:A12)"[/B][/COLOR]
    Range("A14").Formula = "=ROWS(A3:A12) * COLUMNS(A3:A12)-COUNTBLANK(A3:A12)"
End Sub
 
Last edited:
Upvote 0
You say they all have the same error, but don't describe the error.
What do those approches do that isn't right?
 
Upvote 0
I am apologize! I get busy
I don't main There is an Error, I main the empty cells of array formula are uncountable with this function.

I am sorry about misunderstand from my side.
 
Upvote 0
I am apologize! I get busy
I don't main There is an Error, I main the empty cells of array formula are uncountable with this function.

I am sorry about misunderstand from my side.

What do you want to count?

If empty/blank cells:

=COUNTIFS(A2:A100,"=")

If non-blanks cells:

=COUNTIFS(A2:A100,"<>")
 
Upvote 0

Forum statistics

Threads
1,214,908
Messages
6,122,186
Members
449,071
Latest member
cdnMech

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top