Count cells that do not contain a specific value
Macro Title:
|
Worksheet Variable:
|
Worksheet Name:
|
Range Reference:
range from which you want to count the number of cells that do not contain a specific value |
Cell Reference of specific value:
enter the cell reference that captures the value that you want to count for if it doesn't exist |
Output Cell:
|
First Comment:
' |
Second Comment:
' |
Sub Count_cells_that_do_not_contain_a_specific_value()
'declare a variable
Dim ws As Worksheet
Set ws = Worksheets("Analysis")
'apply the formula to count the number of cells in range (B5:B7) that do not contain the value specified in cell (D5)
ws.Range("E5") = Application.WorksheetFunction.CountIf(ws.Range("B5:B7"), "<>" & "*" & ws.Range("D5") & "*")
End Sub
Sub Count_cells_that_do_not_contain_a_specific_value()
'declare a variable
Dim ws As Worksheet
Dim ws As Worksheet
Set ws = Worksheets("Analysis")
'apply the formula to count the number of cells in range (B5:B7) that do not contain the value specified in cell (D5)
ws.Range("E5") = Application.WorksheetFunction.CountIf(ws.Range("B5:B7"), "<>" & "*" & ws.Range("D5") & "*")
ws.Range("E5") = Application.WorksheetFunction.CountIf(ws.Range("B5:B7"), "<>" & "*" & ws.Range("D5") & "*")
End Sub