JenniferMurphy
Well-known Member
- Joined
- Jul 23, 2011
- Messages
- 2,543
- Office Version
- 365
- Platform
- Windows
I have a little UDF that does some tallies on a column of cells (B2:B5).
<tbody>
</tbody>
I call the UDF from another cell like this:
I want to change that to include the cell above the first data cell (B1) and the cell after the last data cell (B6) so if I add a row, I don't have to edit the UDF call.
But I want the UDF to skip over these boundary cells. Here's my code, which works.
Is there a better way to do this?
Thanks
R/C | A | B |
1 | Group | Rating |
2 | North | 25.2 |
3 | South | 14.7 |
4 | East | 52.0 |
5 | West | 33.8 |
6 | Average | 31.4 |
<tbody>
</tbody>
I call the UDF from another cell like this:
Code:
=Tally(B2:B5)
Code:
=Tally(B1:B6)
Code:
Public Function Tally(Ratings As Range) As String
Dim cell As Range
Dim i As Integer
i = 0
For Each cell In Ratings
i = i + 1
If (i = 1) Or (i = Ratings.Count) Then
GoTo Continue
End If
. . . do the tallies . . .
Continue:
Next cell
. . . complete the calculations and return the results . . .
End Function
Thanks