Hi,
I have a code that extract matched rows and copy to another sheet, But it copy on next empty rows But is copying on Ascending Order (bottom of last records).
I would like to make the change the copy/paste in descending order ( on top of last records)
The snniped that i need to add in the code is
Range.Sort Key1:=Range("A2"), Order1:=xlDescending
This is the original threat:
https://www.excelforum.com/excel-pro...e-matches.html
and this is the original code
Sub Treat()
Dim RefRg As Range, R As Range
Dim WkRg As Range, W As Range
Dim HRg As Range
Dim DataRg As Range
Const WS1Name As String = "Sheet1"
Const WS2Name As String = "Test"
Set RefRg = Sheets(WS1Name).Range("I14:M14")
Set HRg = Sheets(WS1Name).Range("D2:P2")
Set WkRg = Sheets(WS1Name).Range("D3:D12")
For Each R In RefRg
For Each W In WkRg
If (R = W) Then
HRg.Copy Destination:=Sheets(WS2Name).Cells(Rows.Count, "B") '.End(3)(2)
W.Resize(1, HRg.Count).Copy Destination:=Sheets(WS2Name).Cells(Rows.Count, "B").End(3)(2)
End If
Next W
Next R
Application.CutCopyMode = False
MsgBox ("Job Done")
End Sub
Thank you!!
Andy
Bookmarks