Hi, I'm sure this is a simple problem of syntax but I'm trying to learn how to use this function so I can apply it in a larger context within a worksheet. I have the following code:
Sub NextGroup()
Dim b As Double
Range("B1:B100").Name = "SUBcol"
b = WorksheetFunction.CountIf("SUBcol", "SUB")
End Sub
In short, the User enters SUB in Column B to indicate that the previous group is to be subtotaled. Eventually, the code will give the user the ability to add a new group of bars, and to do that, I have to know how many groups already exist. I was hoping to use the COUNTIF function to find the number of times the "SUB" keyword has been entered. To simplify things, I was naming the range and then using it as one of the arguments in the COUNTIF function, but it gives me a Type Mismatch error every time. The arguments for COUNTIF are range and criteria, and it should return a Double. I don't see any obvious problems in my syntax but it bombs out every time I run it.
Thanks for your time!
Bookmarks