Olá,
Experimente:
Sub transfere()
Dim lRow As Long, lastRow As Long, lR As Long, nPlan As String
Application.ScreenUpdating = False
nPlan = ActiveSheet.Name
lastRow = Sheets("Plan1").Cells(Cells.Rows.Count, "B").End(xlUp).Row
Sheets(nPlan).Select
For lR = 3 To lastRow
lRow = Sheets("Plan2").Cells(Cells.Rows.Count, "B").End(xlUp).Row
If UCase(Cells(lR, 1).Value) = UCase("X") Then
Range("A" & lR & ":D" & lR).Select
Selection.Copy
Sheets("Plan2").Select
Range("A" & lRow + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Sheets(nPlan).Select
Range("A" & lR & ":D" & lR).ClearContents
End If
Next
Sheets(nPlan).Select
Range("A3:d" & lastRow).Select
Selection.Sort Key1:=Range("B3"), Order1:=xlAscending, Key2:=Range( _
"C3"), Order2:=xlAscending, Key3:=Range("D3"), Order3:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:= _
xlTopToBottom, DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, _
DataOption3:=xlSortNormal
Application.ScreenUpdating = True
MsgBox "Feito"
Sheets(nPlan).Cells(3, "B").Select
End Sub
Existem mil maneiras de preparar Neston. Invente a sua!
http://www.youtube.com/ExpressoExcel
Postado : 15/09/2013 3:18 pm