VBA Code:
Dim rCol2 As Long
rCol2 = ActiveWorkbook.Worksheets("ANALYTICS").UsedRange.Columns.Count
'
ActiveWorkbook.Worksheets("ANALYTICS").Activate
'
ActiveWindow.SmallScroll Down:=-48
Application.CutCopyMode = False
'
ActiveWorkbook.Worksheets("ANALYTICS").Range(Cells(1, 13), Cells(rCol2, 14)).Select
ActiveWorkbook.Worksheets("ANALYTICS").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("ANALYTICS").Sort.SortFields.Add2 Key:=Range(Cells(1, 13), _
Cells(rCol2, 14)), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
'
With ActiveWorkbook.Worksheets("ANALYTICS").Sort
.SetRange Range(Cells(1, 13), Cells(20, 14))
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
So all of this works fine, except for the very last section. If I take this out, it runs without incident. If I leave it in, I get : "Run-time error '1004': Application-defined or object-defined error
VBA Code:
With ActiveWorkbook.Worksheets("ANALYTICS").Sort
.SetRange Range(Cells(1, 13), Cells(20, 14))
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Anyone have any ideas on why this would be? I used the exact same code in several other places within the workbook with no issues (primarily as a workbook open event where I have it 'refresh' data at the top of a worksheet that gets captured, tallied and sorted.)
This code is inside a module that is directed to from a userform code.
Thanks for any suggestions.