suppose in sheet 1 data from A1 to B3 is as follows
A D
B E
C F
copy this data in sheet 2 also
first experiment with this sample data.
now run the macro "test"
If you want to recheck run first "undo" and then run "test"
I am sure you can modify the macro to suit you.
the macros are
Sub test()
Dim r As Range, j As Integer, k As Integer
Dim dest As Range
Worksheets("sheet1").Activate
j = Range("A1").End(xlDown).Row
Set r = Range("A1").End(xlToRight).Offset(0, 1)
r.Value = 1
Set r = Range(r, Cells(j, r.Column))
r.DataSeries Rowcol:=xlColumns, Type:=xlLinear, _
Step:=1, Trend:=False
Set r = Range("A1").CurrentRegion
Set dest = Range("d9")
r.Copy dest
Set r = dest.CurrentRegion
'MsgBox r.Address
k = dest.End(xlToRight).Column
r.Sort key1:=Cells(dest.Row, k), Order1:=xlDescending, header:=xlNo
r.Copy
dest.End(xlDown).Offset(3, 0).PasteSpecial Transpose:=True
dest.End(xlDown).End(xlDown).End(xlDown).EntireRow.Delete
dest.Select
End Sub
Sub undo()
Worksheets("sheet1").Cells.Clear
Worksheets("sheet2").UsedRange.Copy Worksheets("sheet1").Range("A1")
End Sub
Bookmarks