Count cells that contain text
Macro Title:
|
Worksheet Variable:
|
Range Variable:
|
Output Variable:
|
Worksheet Name:
|
Range Reference:
range from which you want to count the number of cells that contain text |
Output Cell:
|
First Comment:
' |
Second Comment:
' |
Sub Count_cells_that_contain_text()
'declare variables
Dim ws As Worksheet
Dim rng As Range
Dim output As Range
Set ws = Worksheets("Analysis")
Set rng = ws.Range("B5:B9")
Set output = ws.Range("D5")
Set rng = ws.Range("B5:B9")
Set output = ws.Range("D5")
'apply the formula to count cells that contain text
output = Application.WorksheetFunction.CountIf(rng, "*")
End Sub
Sub Count_cells_that_contain_text()
'declare variables
Dim ws As Worksheet
Dim rng As Range
Dim output As Range
Dim ws As Worksheet
Dim rng As Range
Dim output As Range
Set ws = Worksheets("Analysis")
Set rng = ws.Range("B5:B9")
Set output = ws.Range("D5")
Set rng = ws.Range("B5:B9")
Set output = ws.Range("D5")
'apply the formula to count cells that contain text
output = Application.WorksheetFunction.CountIf(rng, "*")
output = Application.WorksheetFunction.CountIf(rng, "*")
End Sub