Apos algumas alterações ele está preenchendo as cinco colunas, porém está incluindo também a linha dois
Segue a fonte com a alteração
Sub FindAllMatches()
'Find all matches on activesheet
'Called by: TextBox_Find_KeyUp event
Dim SearchRange As Range
Dim FindWhat As Variant
Dim FoundCells As Range
Dim FoundCell As Range
Dim arrResults() As Variant
Dim lFound As Long
Dim lSearchCol As Long
Dim lLastRow As Long
Dim i As Variant
If Len(RelReceb.Pesq_Prod.Value) > 1 Then 'Do search if text in find box is longer than 1 character.
Range("a3").Select
'For i = 0 To List_Corpo.ListCount - 1
'List_Corpo.ColumnCount = 5
'Next i
Set SearchRange = ActiveSheet.UsedRange.Cells
FindWhat = RelReceb.Pesq_Prod.Value
'Calls the findall function
Set FoundCells = FindAll(SearchRange:=SearchRange, _
FindWhat:=FindWhat, _
LookIn:=xlValues, _
LookAt:=xlPart, _
SearchOrder:=xlByColumns, _
MatchCase:=False, _
BeginsWith:=vbNullString, _
EndsWith:=vbNullString, _
BeginEndCompare:=vbTextCompare)
If FoundCells Is Nothing Then
ReDim arrResults(1 To 1)
ReDim arrResults(1 To 2)
ReDim arrResults(1 To 3)
ReDim arrResults(1 To 4)
ReDim arrResults(1 To 5)
arrResults(1, 3) = "Dados não cadastrado"
Else
'Add results of FindAll to an array
ReDim arrResults(1 To FoundCells.Count, 1 To 1)
ReDim arrResults(1 To FoundCells.Count, 1 To 2)
ReDim arrResults(1 To FoundCells.Count, 1 To 3)
ReDim arrResults(1 To FoundCells.Count, 1 To 4)
ReDim arrResults(1 To FoundCells.Count, 1 To 5)
lFound = 1
For Each FoundCell In FoundCells
arrResults(lFound, 1) = FoundCell.Value
arrResults(lFound, 2) = FoundCell.Value
arrResults(lFound, 3) = FoundCell.Value
arrResults(lFound, 4) = FoundCell.Value
arrResults(lFound, 5) = FoundCell.Value
lFound = lFound + 1
Next FoundCell
End If
'Populate the list_corpo with the array
Me.List_Corpo.List = arrResults
'List_Corpo.ColumnCount = 5
Else
Me.List_Corpo.Clear
End If
End Sub
Postado : 28/06/2015 1:00 pm