Sort question (of sorts)

  • Thread starter Thread starter Patrick C. Simonds
  • Start date Start date
P

Patrick C. Simonds

The code below runs a sort on the Relief Board worksheet (the worksheet is
not active) the problem is that when you do go to that worksheet the range
A6:J3000 is still selected. Is there any way to clear the selection and have
the cell C6 be active?


ActiveWorkbook.Worksheets("Relief Board").Sort.SortFields.Add
Key:=Range( _
"A7:A3000"), SortOn:=xlSortOnValues, Order:=xlAscending,
DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Relief Board").Sort
.SetRange Range("A6:J3000")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
 
This uses xl2003 .Sort syntax, but will work in xl2007:

With ActiveWorkbook.Worksheets("Relief Board")
With .Range("a7:j3000")
.Sort key1:=.Columns(1), order1:=xlAscending, _
dataoption1:=xlSortNormal, _
Header:=xlYes, MatchCase:=False, Orientation:=xlTopToBottom
End With
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Applying Variables to SORT 4
Modify Sort Routine to inlcude All Data 2
Undo Macro Action 3
Sorting Question 5
Sort by one column then another. 2
Clear Check Box 2
VBA 2 Codes 2
Pictures not being sorted in VBA 2

Back
Top