JUNIOR TARGINO
05-11-2010 11:28:22
-----------------------------------------------------------------------
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
' Verifica se o valor alterado foi na célula E1
If Not Intersect([B2], Target) Is Nothing Then
Dim lastRow As Long
Dim lastResultRow As Long
Dim x As Long
' Verifica qual a ultima célula preenchida
lastRow = Plan22.Cells(Rows.Count, 1).End(xlUp).Row
' Apaga valores anteriores
Plan23.Range("A5:M65536").Clear
lastResultRow = 5
' Ciclo em todas as linhas
For x = 2 To lastRow '1 coluna pequisa
' verifica se o valor é igual ao da pesquisa
If UCase(Plan22.Cells(x, 1).Value) = UCase(Plan23.[B2].Value) Then
'Plan22.Cells(x, 2).Value = Plan23.[F2].Value Then '1 coluna pequisa
' Copia os valores
Plan23.Cells(lastResultRow, 2).Value = Plan22.Cells(x, 2).Value
Plan23.Cells(lastResultRow, 3).Value = Plan22.Cells(x, 4).Value
Plan23.Cells(lastResultRow, 4).Value = Plan22.Cells(x, 6).Value
Plan23.Cells(lastResultRow, 5).Value = Plan22.Cells(x, 8).Value
Plan23.Cells(lastResultRow, 6).Value = Plan22.Cells(x, 10).Value
Plan23.Cells(lastResultRow, 7).Value = Plan22.Cells(x, 12).Value
Plan23.Cells(lastResultRow, 8).Value = Plan22.Cells(x, 14).Value
Plan23.Cells(lastResultRow, 9).Value = Plan22.Cells(x, 16).Value
Plan23.Cells(lastResultRow, 10).Value = Plan22.Cells(x, 18).Value
Plan23.Cells(lastResultRow, 11).Value = Plan22.Cells(x, 20).Value
Plan23.Cells(lastResultRow, 12).Value = Plan22.Cells(x, 22).Value
Plan23.Cells(lastResultRow, 13).Value = Plan22.Cells(x, 24).Value
lastResultRow = lastResultRow + 1
End If
Next
'
End If
End Sub
Agradeço a todos!!! colaboradores!!