Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Hide all "except" the visible selected range(s)? | Excel Worksheet Functions | |||
Hide all "except" the visible selected range(s)? | Excel Worksheet Functions | |||
Hide all "except" the visible selected range(s)? | Excel Worksheet Functions | |||
Range("B2").AutoFill Destination:=Range("GX1", ActiveCell) ... Fails but why? | Excel Programming | |||
Setting "r" to = range selected in an IF statement? | Excel Programming |