Results 1 to 2 of 2
Thread: Sort not quite working...
2011-10-17, 17:03 #1
- Join Date
- Nov 2002
- London, Gtr London, England
- Thanked 0 Times in 0 Posts
Sort not quite working...
I am doing something stupid and am too tired to see what is probably obvious! This was originally a recorded macro (2010) which I then adjusted. I have sliced out the relevant bits from arather larger module. The error is to do with .SetRange
Dim sSortArea As Sort ' the sort itself Dim wsThisWorkSheet As Worksheet ' the worksheet Set wsThisWorkSheet = ActiveSheet Set sSortArea = wsThisWorkSheet.Sort 'Sort the data, based on two columns the ref number and the date sSortArea.SortFields.Clear sSortArea.SortFields.Add Key:=Range("WorkRef"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortTextAsNumbers sSortArea.SortFields.Add Key:=Range("MsgDate"), SortOn:=xlSortOnValues, Order:=xlAscending With sSortArea .SetRange Range("rActiveRange") .Header = xlYes .MatchCase = False .Orientation = xlTopToBottom .SortMethod = xlPinYin .Apply End With
Thank you................. liz
Last edited by lizat; 2011-10-17 at 17:59.
2011-10-18, 04:46 #2
- Join Date
- Dec 2000
- Burwash, East Sussex, United Kingdom
- Thanked 191 Times in 177 Posts
Is rActiveRange a Range object variable, or the name of a range? If the former, then it should be:
Microsoft MVP - Excel