Hi,
Quote:
|
I've got a very simple task. I've got a range of say H10:H39. Each of these cells is going to either say Y, N, or NA - I want to just ... have a cell beneath the column that sums up the number of Ys in the range. That is all.
|
This can be done with a formula, so there's probably no need to use Excel VBA. It's really a count, not a sum, and there is one condition so the COUNTIF() worksheet function is suitable.
Say your total is in the cell H40, put this formula in that cell:
=COUNTIF(H10:H39,"y")
The "y" string condition is not case sensitive.
If this is part of a process you are automating, then you can put the formula into the cell using Excel VBA by using the Range.Formula property. An example would be:
Code:
Sub foo()
Worksheets("Sheet1").Range("H40").Formula = "=COUNTIF(H10:H39,""y"")"
End Sub
Hope that helps?