The example i have below will copy specific rows from worksheet 1 to worksheet 2 if "YES" is found in column E. I need it to only copy specific columns of the rows, being B & C.
Fund Account Amount Gain/Loss As/Of? (Y/N)
1 11111 $15,000.00 -$1.51 YES
1 22222 $32,158.52 $78.14 YES
2 123123 $1.00 $0.00 NO
Code:
Sub As_Of_Analysis_Sorting()
Dim lr As Long, lr2 As Long, r As Long
lr = Sheets("All Trades").Cells(Rows.Count, "A").End(xlUp).Row
lr2 = Sheets("As-Of Trades").Cells(Rows.Count, "A").End(xlUp).Row
For r = lr To 2 Step -1
If Range("E" & r).Value = "YES" Then
Rows(r).Copy Destination:=Sheets("As-Of Trades").Range("A" & lr2 + 1)
lr2 = Sheets("As-Of Trades").Cells(Rows.Count, "A").End(xlUp).Row
End If
Range("A1").Select
Next r
End Sub
What you need to do is to do a
For
with a counter that will read all the cells with something in the sheet from up to down.F
is the row of the new sheet where you want to place the stuff.Try something similar to this:
Try this:
New request: