ThrottleWorks
Excel Ninja
Hi,
I am using below mentioned code to sort data. I am not facing any issue with this code.
However I wanted to know if below code is correct, in other words, I want to make sure, code will not generate erroneous result.
So that I can repeat same code elsewhere without any worry.
I had checked this code with dummy data several times and did not found any issue.
Could you please review if you get time.
I am using below mentioned code to sort data. I am not facing any issue with this code.
However I wanted to know if below code is correct, in other words, I want to make sure, code will not generate erroneous result.
So that I can repeat same code elsewhere without any worry.
I had checked this code with dummy data several times and did not found any issue.
Could you please review if you get time.
Code:
Sub Process_Raw_Data()
Dim TempRng As Range
Dim TempLr As Long
'Sheet Name and Column Position is already changed to suit below code
TempLr = RawSht.Cells(RawSht.Rows.Count, 1).End(xlUp).Row
Set TempRng = RawSht.Range(RawSht.Cells(1, 1), RawSht.Cells(TempLr, 37))
'Sort Data
ToolData.Worksheets("Sheet1").Sort.SortFields.Clear
ToolData.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("I2:I" & TempLr) _
, SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ToolData.Worksheets("Sheet1").Sort
.SetRange TempRng
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub