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

Quote:
Originally Posted by Caveman1957 View Post
When in a worksheet I can manually select all cells by doing a control-A is there an equivalent I can use when coding?

I tried recording a macro and it just enters the particular range that was selected so is not dynamic in the way control-A is.

I am trying to do this as a precondition before doing a sort on all the data.
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