Sort question (of sorts)

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
 
L

Leith Ross

Hello Patrick,

Use the statement *Application.CutCopMode = False* to deselect th
data. Then add *Range("C6").Select*.

====================================
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
Application.CutCopyMode = False
Worksheets("Relief Board").Range("C6").Select
===================================

--
Leith Ros

Sincerely,
Leith Ross

'The Code Cage' (http://www.thecodecage.com/
 
D

Dave Peterson

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
 
P

Patrick C. Simonds

Sorry but it errors out on:

Worksheets("Relief Board").Range("C6").Select
 
Top