View Single Post
  #2   Report Post  
Caveman1957 Caveman1957 is offline
Junior Member
 
Posts: 18
Default

Quote:
Originally Posted by Caveman1957 View Post
I have come up with this code below but now am having a problem with what to put in the .SetRange to use column A in the UsedRange selection.

ActiveWorkbook.Worksheets("SS").Sort.SortFields.Cl ear
ActiveWorkbook.Worksheets("SS").Sort.SortFields.Ad d Key:=Sheet8.UsedRange, _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("SS").Sort
.SetRange Range(?????????)
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Turned out I had the ranges back to front in my mind :P

Code works if set as follows

ActiveWorkbook.Worksheets("SS").Sort.SortFields.Cl ear
ActiveWorkbook.Worksheets("SS").Sort.SortFields.Ad d Key:=Range("A:A"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("SS").Sort
.SetRange Sheet8.UsedRange
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With

Hope this helps someone else save some pain