ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Counting literals in cells (https://www.excelbanter.com/excel-programming/312895-counting-literals-cells.html)

Joeyej

Counting literals in cells
 
I'm trying to figure a quick way using a macro to count the results of
a survey recorded in an Excel spreadsheet. Each record in the survey
has cells that may contain "Yes", "No", "Maybe", "Sometimes" and
"Occasionally". Is there a macro that can count occurrences of each
literal and report their totals?

Thanks,

Joeyej

Norman Jones

Counting literals in cells
 
Hi Joeyei,

In excel you can use the CountIf worksheet function:

=CountIf(A1:A100,"Yes")

If you need to do this in code:

Dim Var As Long

Var = Application.CountIf(Range("A1:A100"), "Yes")

---
Regards,
Norman



"Joeyej" wrote in message
om...
I'm trying to figure a quick way using a macro to count the results of
a survey recorded in an Excel spreadsheet. Each record in the survey
has cells that may contain "Yes", "No", "Maybe", "Sometimes" and
"Occasionally". Is there a macro that can count occurrences of each
literal and report their totals?

Thanks,

Joeyej





All times are GMT +1. The time now is 04:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com