Já resolvi com o seguinte código:
Private Sub UserForm_Initialize()
Dim varFOLHA As Variant
Dim colPAROQUIANOS As Collection
Dim lngLast As Long
Dim lngLin As Long
Dim lng As Long
Set colPAROQUIANOS = New Collection
'Definir quais planilhas devem ser pesquisadas:
With ThisWorkbook
mvarFOLHAS = Array(.Worksheets("2017") _
, .Worksheets("2018") _
, .Worksheets("2019") _
, .Worksheets("2020") _
, .Worksheets("2021"))
End With
'Obter todos os carros de forma distinta:
On Error Resume Next
For Each varFOLHA In mvarFOLHAS
With varFOLHA
lngLast = .Cells(.Rows.Count, "A").End(xlUp).Row
For lngLin = 2 To lngLast
colPAROQUIANOS.Add CStr(.Cells(lngLin, "A")) _
, CStr(.Cells(lngLin, "A"))
Next lngLin
End With
Next varFOLHA
End Sub
Private Sub TextBox1_Change()
'Call pesquisanome21
Call pesquisanome
Dim varFOLHA As Variant
Dim varFOLHAS As Variant
Dim wksAux As Worksheet
Dim lngLast As Long
Dim lngLin As Long
Dim lngAux As Long
Dim lng As Long
If Me.TextBox1 = "" Then Exit Sub
Application.ScreenUpdating = False
Set wksAux = ThisWorkbook.Sheets("Aux")
'Limpa planilha auxiliar:
wksAux.Cells.ClearContents
mvarFOLHAS(1).Rows(1).Copy
wksAux.Rows(1).PasteSpecial xlPasteValues
'Busca o carro especificado na caixa de combinação:
lngAux = 2
For Each varFOLHA In mvarFOLHAS
With varFOLHA
lngLast = .Cells(.Rows.Count, "A").End(xlUp).Row
For lngLin = 2 To lngLast
If CStr(.Cells(lngLin, "A")) = Me.TextBox1 Then
.Rows(lngLin).Copy
wksAux.Rows(lngAux).PasteSpecial xlPasteValues
'wksAux.Cells(lngAux, "I") = .Name
'wksAux.Cells(lngAux, "J") = wksAux.Cells(lngAux, "A").Address
lngAux = lngAux + 1
End If
Next lngLin
End With
Next varFOLHA
'Exibe o resultado da busca na caixa de listagem:
With wksAux
lngLast = .Cells(.Rows.Count, "A").End(xlUp).Row
Me.ListBox2.RowSource = "'[" & ThisWorkbook.Name & "]" _
& .Name & "'!" & .Range("C2:F500").Resize(lngLast - 1, 9).Address
End With
Application.ScreenUpdating = True
Application.CutCopyMode = False
End Sub
Att.,
RM
Postado : 17/03/2017 5:36 pm