Caros colegas, boa tarde.
Tenho um formulário onde tem um listview, porém, na minha guia, tem mais de 4 mil cadastros. Ao fazer o listview trazer esses cadastros dá este erro:
Erro em tempo de execução '13': Tipo incompatíveis.
Segue abaixo o código que estou utilizando:
Dim valor_pesq As String
Dim linha1 As Long
Dim coluna1 As Long
Dim valor_celula
Dim id
valor_pesq = TextBox1.Text
coluna1 = 2
linha1 = 2
id = TextBox1
ListView1.ListItems.Clear
Plan4.Select
With Plan4
While .Cells(linha1, coluna1).Value <> Empty
valor_celula = .Cells(linha1, coluna1).Value
If UCase(Left(valor_celula, Len(valor_pesq))) = UCase(valor_pesq) Then
Set li = ListView1.ListItems.Add(Text:=Plan4.Cells(linha1, 1).Value) 'Matrícula
li.ListSubItems.Add Text:=Plan4.Cells(linha1, 2).Value 'Colaborador
li.ListSubItems.Add Text:=Plan4.Cells(linha1, 3).Value 'Função
li.ListSubItems.Add Text:=Plan4.Cells(linha1, 4).Value
li.ListSubItems.Add Text:=Plan4.Cells(linha1, 5).Value
li.ListSubItems.Add Text:=Plan4.Cells(linha1, 6).Value
li.ListSubItems.Add Text:=Plan4.Cells(linha1, 7).Value
li.ListSubItems.Add Text:=Plan4.Cells(linha1, 8).Value
li.ListSubItems.Add Text:=Plan4.Cells(linha1, 9).Value
li.ListSubItems.Add Text:=Plan4.Cells(linha1, 10).Value
li.ListSubItems.Add Text:=Plan4.Cells(linha1, 11).Value
li.ListSubItems.Add Text:=Plan4.Cells(linha1, 12).Value
li.ListSubItems.Add Text:=Plan4.Cells(linha1, 13).Value
li.ListSubItems.Add Text:=Plan4.Cells(linha1, 14).Value
li.ListSubItems.Add Text:=Plan4.Cells(linha1, 15).Value
li.ListSubItems.Add Text:=Plan4.Cells(linha1, 16).Value
li.ListSubItems.Add Text:=Plan4.Cells(linha1, 17).Value
li.ListSubItems.Add Text:=Plan4.Cells(linha1, 18).Value
li.ListSubItems.Add Text:=Plan4.Cells(linha1, 19).Value
li.ListSubItems.Add Text:=Plan4.Cells(linha1, 20).Value
li.ListSubItems.Add Text:=Plan4.Cells(linha1, 21).Value
li.ListSubItems.Add Text:=Plan4.Cells(linha1, 22).Value
End If
Label271 = Me.ListView1.ListItems.Count
Set Lv = Nothing
linha1 = linha1 + 1
Wend
End With
Um abraço.