Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Sort of range leaves range "selected"

I have a dozen or so worksheets with the same template, and my code does a
sort on a range within each sheet. After the sort, tho, the range is still
"highlighted", as if I had selected the range (which I didn't, not with
"select", at least), i.e., it's shaded just as if I had clicked on the upper
left cell of the range and dragged down to the lower right. I would like the
range to remain visually unaltered, but I can't figure out how.

Thanks in advance

Mike J
  #2   Report Post  
Posted to microsoft.public.excel.programming
XP XP is offline
external usenet poster
 
Posts: 389
Default Sort of range leaves range "selected"

Not sure if this would help, but you could just add one line at the end of
your sort code to select one cell of your choice, for example:

[A2].Select

Hope this helps.

"Mike Jamesson" wrote:

I have a dozen or so worksheets with the same template, and my code does a
sort on a range within each sheet. After the sort, tho, the range is still
"highlighted", as if I had selected the range (which I didn't, not with
"select", at least), i.e., it's shaded just as if I had clicked on the upper
left cell of the range and dragged down to the lower right. I would like the
range to remain visually unaltered, but I can't figure out how.

Thanks in advance

Mike J

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default Sort of range leaves range "selected"

mike - using this sub on excel 2000, my ranges don't get
highlighted.........

For Each ws In wb.Worksheets
ws.Activate
myLastRow = ws.Cells(10000, 1).End(xlUp).Row
Set myRange = ws.Range("a1:b" & myLastRow)
myRange.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlNo,
_
OrderCustom:=1, Orientation:=xlTopToBottom
Next ws

don't know why your ranges are highlighted.
susan



On Jul 25, 12:23*pm, Mike Jamesson
wrote:
I have a dozen or so worksheets with the same template, and my code does a
sort on a range within each sheet. *After the sort, tho, the range is still
"highlighted", as if I had selected the range (which I didn't, not with
"select", at least), i.e., it's shaded just as if I had clicked on the upper
left cell of the range and dragged down to the lower right. *I would like the
range to remain visually unaltered, but I can't figure out how.

Thanks in advance

Mike J


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Sort of range leaves range "selected"

Thanks for the response, here's my code:

Sub SortTallies(targSheet As Worksheet)
Dim targRange As Range
' Application.ScreenUpdating = False 'doesn't help
Set targRange = targSheet.Range("TargDates")
Set targRange = Range(targRange, targRange.End(xlDown))
Set targRange = Range(targRange, targRange.End(xlToRight))
targSheet.Sort.SortFields.Clear
targSheet.Sort.SortFields.Add Key:=targRange.Range( _
"A1:A8"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With targSheet.Sort
.SetRange targRange
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
.SortFields.Clear 'didn't work to clear visible "selection" effects
End With
' Set targRange = targSheet.Range("A1") 'didn't work to clear visible
"selection" effects
' targRange.Select 'bombed
' Application.ScreenUpdating = True
End Sub

As you can see, I used a recorded macro as my basis; also, I don't want to
select either the sheets or the ranges, and have successfully avoided doing
so. But then when I go to the sheets, the area that got sorted is "selected"
visually, and each sheet shows this phenomenon. I'm using Excel 2007 SP1,
btw.

Thanks again

Mike

"Susan" wrote:

mike - using this sub on excel 2000, my ranges don't get
highlighted.........

For Each ws In wb.Worksheets
ws.Activate
myLastRow = ws.Cells(10000, 1).End(xlUp).Row
Set myRange = ws.Range("a1:b" & myLastRow)
myRange.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlNo,
_
OrderCustom:=1, Orientation:=xlTopToBottom
Next ws

don't know why your ranges are highlighted.
susan



On Jul 25, 12:23 pm, Mike Jamesson
wrote:
I have a dozen or so worksheets with the same template, and my code does a
sort on a range within each sheet. After the sort, tho, the range is still
"highlighted", as if I had selected the range (which I didn't, not with
"select", at least), i.e., it's shaded just as if I had clicked on the upper
left cell of the range and dragged down to the lower right. I would like the
range to remain visually unaltered, but I can't figure out how.

Thanks in advance

Mike J



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
Hide all "except" the visible selected range(s)? Spiky Excel Worksheet Functions 2 August 4th 08 09:56 PM
Hide all "except" the visible selected range(s)? Pierre Excel Worksheet Functions 0 August 2nd 08 07:17 PM
Hide all "except" the visible selected range(s)? Pierre Excel Worksheet Functions 2 August 1st 08 09:21 PM
Range("B2").AutoFill Destination:=Range("GX1", ActiveCell) ... Fails but why? [email protected] Excel Programming 2 March 13th 07 12:10 PM
Setting "r" to = range selected in an IF statement? Simon Lloyd[_805_] Excel Programming 4 July 1st 06 05:53 PM


All times are GMT +1. The time now is 11:10 PM.

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

About Us

"It's about Microsoft Excel"