essentially, i'm trying to loop through many rows and if two lines have the same blotter, settlement date ("sd"), and they're a pair ....one being a Buy, other a Sell, one being Active, the other ebing Cancelled ....if that's the case, move those rows to another tab called "cancelled" and repeat the process until all pairs have been cut and pasted over
also, the pair will not necessarily be consecutive rows (e.g., the active one might be on row 10, the equivaneltn cancelled one might be row 30).
also, the pair will not necessarily be consecutive rows (e.g., the active one might be on row 10, the equivaneltn cancelled one might be row 30).
Code:
Sheets("A").Select
Application.ScreenUpdating = False
finalrow = Cells(Rows.Count, "A").End(xlUp).Row
For i = 2 To finalrow
For j = 2 To finalrow
'establish blotter, etc.
blotter = Range("p" & i)
net_amt = Abs(Range("e" & i))
buy_sold_indic = Range("l" & i)
sd = Range("x" & i)
cancel_indic = Range("o" & i)
blotter2 = Range("p" & j)
net_amt2 = Abs(Range("e" & j))
buy_sold_indic2 = Range("l" & j)
sd2 = Range("x" & j)
cancel_indic2 = Range("o" & j)
'if blotter, net amount, etc. for the cancelled trade equals the blotter, net amount, etc. for non-cancelled trades, and the cancelled and non-cancelled trades buy/sold and cancel indicators don't equal to each other, then cut the cancelled row and the non-cancelled row to the Cancelled tab
If blotter = blotter2 And net_amt = net_amt2 And sd = sd2 And buy_sold_indic <> buy_sold_indic2 And cancel_indic <> cancel_indic2 Then
Range("a" & i).EntireRow.Cut
Sheets("Cancelled").Activate
totalrow = Cells(Rows.Count, "A").End(xlUp).Row + 1
Range("a" & totalrow).Select
ActiveSheet.Paste
Sheets("A").Activate
Range("a" & j).EntireRow.Cut
Sheets("Cancelled").Activate
totalrow = Cells(Rows.Count, "A").End(xlUp).Row + 1
Range("a" & totalrow).Select
ActiveSheet.Paste
Sheets("A").Activate
End If
Next j
Next i