I'm trying to do an excel that counts the number of times that a certain letter appears in a table column.
What I'm trying to do is to create a dynamic table, in which i can always add new lines. Because of that, i need a function that has as a parameter one of the columns, which counts the number of times that another parameter appears.
Example, count the number of "shift" in the "column" (:
Function sumColumnShifts(column As Integer, shift As range) As Integer
sumColumnShifts = sumDayShifts(ActiveSheet.ListObjects("foo").ListColumns(column).range.Select, shift)
End Function
Public Function sumDayShifts(ByVal Target As range, shift As range) As Variant
Dim res As Integer
res = 0
For Each cell In Target
If shift.cells(1, 1).Value = cell.Value Then
res = res + 1
End If
Next
sumDayShifts = res
End Function
The problem here is the function can't find the table, but the table exists. What am I doing wrong? Is it the ActiveSheet.ListObjects("foo").ListColumns(column).range.Select? This is not a range? I can't access this in a function?
Thanks.
