Уважаемые гуру при нажатии клавиш del,backspace,escape(чтобы очистить форму) combo box активен выдает ошибку следующего типа:
run-time error '381': Could not get the List property.Invalid property array index.
Вот код из user form:
Option Explicit
Private Sub Combobox1_Change()
Dim iSotrud As String
iSotrud = Me.ComboBox1.List(Me.ComboBox1.ListIndex)
If ActiveSheet.AutoFilterMode Then
Range("b1").AutoFilter Field:=2, Criteria1:=iSotrud
End If
UserForm2.StartUpPosition = 2
End Sub
Private Sub CommandButton1_Click()
Selection.AutoFilter Field:=2
End Sub
Private Sub UserForm_Initialize()
Dim AllCells As Range, Cell As Range
Dim NoDupes As New Collection
Dim i As Integer, j As Integer
Dim Swap1, Swap2, Item
Set AllCells = Range("b2:b" & Cells(Rows.Count, 2).End(xlUp).Row)
On Error Resume Next
For Each Cell In AllCells
NoDupes.Add Cell.Value, CStr(Cell.Value)
Next Cell
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
For Each Item In NoDupes
UserForm2.ComboBox1.AddItem Item
Next Item
End Sub
почему не получается очистить форму ?
где ошибка?
run-time error '381': Could not get the List property.Invalid property array index.
Вот код из user form:
Option Explicit
Private Sub Combobox1_Change()
Dim iSotrud As String
iSotrud = Me.ComboBox1.List(Me.ComboBox1.ListIndex)
If ActiveSheet.AutoFilterMode Then
Range("b1").AutoFilter Field:=2, Criteria1:=iSotrud
End If
UserForm2.StartUpPosition = 2
End Sub
Private Sub CommandButton1_Click()
Selection.AutoFilter Field:=2
End Sub
Private Sub UserForm_Initialize()
Dim AllCells As Range, Cell As Range
Dim NoDupes As New Collection
Dim i As Integer, j As Integer
Dim Swap1, Swap2, Item
Set AllCells = Range("b2:b" & Cells(Rows.Count, 2).End(xlUp).Row)
On Error Resume Next
For Each Cell In AllCells
NoDupes.Add Cell.Value, CStr(Cell.Value)
Next Cell
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
For Each Item In NoDupes
UserForm2.ComboBox1.AddItem Item
Next Item
End Sub
почему не получается очистить форму ?
где ошибка?