Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'стандартная экселевская функция COUNTIF не работает со строками больше 256 символов (
- 'This implementation does not require redundant call argument
- Public Function CountDuplicates_(rngRange As Range) As Integer
- Dim wsCur As Worksheet
- Dim CallerRange As Range
- Dim rngCol As Integer
- Dim CheckCell As String
- Dim theCell As String 'Current test value
- Dim CallerRow, StartRow, EndRow, iRow As Integer
- Set CallerRange = Application.Caller
- rngCol = rngRange.Cells(1, 1).Column
- CallerRow = CallerRange.Row
- StartRow = rngRange.Cells(1, 1).Row
- EndRow = StartRow + rngRange.Rows.Count - 1
- CountDuplicates_ = 0 ' API FIX
- Set wsCur = ThisWorkbook.Application.Caller.Worksheet
- CheckCell = wsCur.Cells(CallerRow, rngCol).Value
- If CheckCell = "" Then
- 'Return operator simulation
- GoTo EndFunction
- End If
- 'FIXME: Remove hardcode. Use Model, Luke
- For iRow = StartRow To EndRow
- If iRow = CallerRow Then
- 'Continue operator simulation
- GoTo Continue_iRow
- End If
- theCell = wsCur.Cells(iRow, rngCol).Value
- If theCell <> CheckCell Then
- 'Current Cell is not equals test value
- 'Continue operator simulation
- GoTo Continue_iRow
- End If
- CountDuplicates_ = CountDuplicates_ + 1
- Continue_iRow:
- Next iRow
- EndFunction:
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement