I have this code and it should look through a table from A to P, and when it finds the value "andr" it should copy the entire row A-P in a New Sheet. Right now only things it does, it copies the a2 - p2 in a new sheet. Im really new with vba Please help!!
enter code here
Application.ScreenUpdating = False
Application.DisplayAlerts = False
On Error Resume Next
Dim i As Long
Dim ws As Worksheet, nws As Worksheet
Set ws = ActiveSheet
Range("A1:P1").Copy
Lastrow = Cells(Rows.Count, "E").End(xlUp).Row
ActiveWorkbook.Sheets.Add after:=Worksheets(Worksheets.Count)
ActiveSheet.Name = "NewSheet"
Range("A1").Select
ActiveSheet.Paste
Set nws = ActiveSheet
For i = 2 To Lastrow
ws.Select
If UCase(Cells(i, "E")) = "FULL" Then
Range(("A" & i) & ":" & ("P" & i)).Copy
nws.Select
nsLR = Cells(Rows.Count, "E").End(xlUp).Row
If Range("A1") = "" Then
nsLR = 0
End If
Range("A" & nsLR + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Paste:=xlcolumnwidths
End If
Next i
Application.ScreenUpdating = True
Application.DisplayAlerts = True
On Error GoTo 0
nws.Select
Range("A2").Select
Aucun commentaire:
Enregistrer un commentaire