Hello all, requesting help with sorting...the macro I have is recorded, but the recorder sets a specific range...the data doesnt always fall in this range, sometimes its longer/shorter....does anyone know how to sort data regardless of where the last line of data is? here is the code I have (the bolded part is what im talking about)
Sub CC2()
'
Columns("A:A").RemoveDuplicates Columns:=1, Header:=xlYes
Range("B2").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-1],DLL!C[-1],1,FALSE)"
ActiveCell.Offset(0, -1).Select
Selection.End(xlDown).Select
ActiveCell.Offset(0, 1).Select
Range(Selection, Selection.End(xlUp)).Select
Selection.FillDown
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add2 Key:=Range( _
"B2:B1474"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").Sort
.SetRange Range("A1:F1474")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
Bookmarks