ThrottleWorks
Excel Ninja
Hi,
I am trying to sort a data.
I am finding header "reference" in the sheet and sort the data with base as "reference".
My problem is once I am finding 'reference' in the data, macro takes Column "U" as static.
The header 'reference' in U Column but my problem is 'reference' can be in Column T or R also.
Howe do I make my sorting Column dynamic.
I want to change ":=Range("U2:U65000")," to a dynamic range.
Can anyone please help me this.
Kindly note I have recorded below mentioned macro for my use.
I am trying to sort a data.
I am finding header "reference" in the sheet and sort the data with base as "reference".
My problem is once I am finding 'reference' in the data, macro takes Column "U" as static.
The header 'reference' in U Column but my problem is 'reference' can be in Column T or R also.
Howe do I make my sorting Column dynamic.
I want to change ":=Range("U2:U65000")," to a dynamic range.
Can anyone please help me this.
Kindly note I have recorded below mentioned macro for my use.
Code:
Collate.Select
Range("a1").Select
Selection.AutoFilter
Cells.Find(What:="Reference", After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows, Search Direction:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
ActiveWorkbook.Worksheets("CollatedData").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("CollatedData").AutoFilter.Sort.SortFields.Add Key _
:=Range("U2:U65000"), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("CollatedData").AutoFilter.Sort
.Header = xlYes
.Match Case = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With