Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 343
Default Sort question (of sorts)

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Sort question (of sorts)

ActiveWorkbook.Worksheets("Relief Board").Activate
Range("C6").Select
--
Gary''s Student - gsnu2007k
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 343
Default Sort question (of sorts)

Thanks, but I do not want the worksheet to become active.



"Gary''s Student" wrote in message
...
ActiveWorkbook.Worksheets("Relief Board").Activate
Range("C6").Select
--
Gary''s Student - gsnu2007k


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sort question (of sorts)


Hello Patrick,

Use the statement *Application.CutCopMode = False* to deselect the
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 Ross

Sincerely,
Leith Ross

'The Code Cage' (http://www.thecodecage.com/)
------------------------------------------------------------------------
Leith Ross's Profile: http://www.thecodecage.com/forumz/member.php?userid=75
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=51540

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 343
Default Sort question (of sorts)

Sorry but it errors out on:

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


"Leith Ross" wrote in message
...

Hello Patrick,

Use the statement *Application.CutCopMode = False* to deselect the
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 Ross

Sincerely,
Leith Ross

'The Code Cage' (http://www.thecodecage.com/)
------------------------------------------------------------------------
Leith Ross's Profile:
http://www.thecodecage.com/forumz/member.php?userid=75
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=51540




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Sort question (of sorts)

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



"Patrick C. Simonds" wrote:

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


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to make rows 'sort with' between sheets during separate sorts Margo Excel Worksheet Functions 4 November 9th 07 08:34 PM
How to I sort in 2 worsheets where an unlinked column sorts as wel CrazyGnome1966 Excel Discussion (Misc queries) 1 August 8th 06 08:03 PM
When I try to sort in Excel only part of the table sorts jrw562 Excel Discussion (Misc queries) 6 March 5th 06 08:31 PM
sort in excel that sorts digikey Albert Mulder Excel Worksheet Functions 1 March 1st 06 07:59 PM
How to exclude header row from sort button sorts? JCabo Excel Discussion (Misc queries) 1 March 25th 05 11:25 PM


All times are GMT +1. The time now is 08:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"