Rom213 » 10.10.2006 (Вт) 0:15
Выскакивает при следующем коде коде, а не нравится NoDupes.Add Cell, CStr(Cell)
Function CreateList(rng As Range, Optional strFilter, Optional intHOffset)
Dim Cell As Range
Dim NoDupes As New Collection
Dim i As Long, j As Long
Dim Swap1, Swap2, Item, Temp
On Error Resume Next
If IsMissing(strFilter) Then
For Each Cell In rng
NoDupes.Add Cell, CStr(Cell)
Next Cell
Else
For Each Cell In rng
If Cell = strFilter Then NoDupes.Add Cell.Offset(, intHOffset), _
CStr(Cell.Offset(, intHOffset))
Next Cell
End If
On Error GoTo 0
For i = 1 To NoDupes.Count - 1
For j = i + 1 To NoDupes.Count
If NoDupes(i) > NoDupes(j) Then
Swap1 = NoDupes(i)
Swap2 = NoDupes(j)
NoDupes.Add Swap1, before:=j
NoDupes.Add Swap2, before:=i
NoDupes.Remove i + 1
NoDupes.Remove j + 1
End If
Next j
Next i
ReDim Temp(1 To NoDupes.Count): i = 0
For Each Item In NoDupes
i = i + 1
Temp(i) = Item
Next Item
CreateList = Temp
End Function