C
cda_cmd
I have a function:
Code:
--------------------
Public Function PositionCount(pos As String, rge As Range) As Integer
Dim counter As Integer
counter = 0
For Each r In rge.Cells
If r.Value = pos Then counter = counter + 1
Next r
PositionCount = counter
End Function
--------------------
The function is used like this:
=PositionCount(A4,'1'!L13:L300)
Cell A4 simply contains a string. This string is what is being
'searched' for.
I have 31 sheets, named 1 .. 31
At the moment I have an annoyingly long formula like this:
=PositionCount(A4,'31'!L13:L300)+
...
PositionCount(A4,'1'!L13:L300)
Each of those checks the same range on a different sheet.
How should my code be changed so that it will do exactly the same
thing, but look up the given range on the 31 different sheets?
Code:
--------------------
Public Function PositionCount(pos As String, rge As Range) As Integer
Dim counter As Integer
counter = 0
For Each r In rge.Cells
If r.Value = pos Then counter = counter + 1
Next r
PositionCount = counter
End Function
--------------------
The function is used like this:
=PositionCount(A4,'1'!L13:L300)
Cell A4 simply contains a string. This string is what is being
'searched' for.
I have 31 sheets, named 1 .. 31
At the moment I have an annoyingly long formula like this:
=PositionCount(A4,'31'!L13:L300)+
...
PositionCount(A4,'1'!L13:L300)
Each of those checks the same range on a different sheet.
How should my code be changed so that it will do exactly the same
thing, but look up the given range on the 31 different sheets?