Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sorting Range Help

I Have a problem i am not sure how to solve. I have created a Sort
option seen below my problem is that i do not want to always stop in
N24. Is there a way to solve this? Thanks in advance.

Sub Sorty()

Range("A12:N24").Select
Selection.Sort Key1:=Range("D12"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Range("A12:B12").Select
Selection.AutoFill Destination:=Range("A12:B23"),
Type:=xlFillDefault
Range("A12:B23").Select
End Sub


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,173
Default Sorting Range Help

There is seldom any need for all the 'Select' you have as you can operate on
the range without selecting, but to simply cure your issue modify the code
as shown

Sub Sorty()
Dim lLastRow as Long
lLastRow=Range("N65536").End(xlUp).Row
Range("A12:"&lLastRow).Select
Selection.Sort Key1:=Range("D12"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Range("A12:B12").Select
Selection.AutoFill Destination:=Range("A12:B23"),
Type:=xlFillDefault
Range("A12:B23").Select
End Sub


--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
HIS


"HelpMe " wrote in message
...
I Have a problem i am not sure how to solve. I have created a Sort
option seen below my problem is that i do not want to always stop in
N24. Is there a way to solve this? Thanks in advance.

Sub Sorty()

Range("A12:N24").Select
Selection.Sort Key1:=Range("D12"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Range("A12:B12").Select
Selection.AutoFill Destination:=Range("A12:B23"),
Type:=xlFillDefault
Range("A12:B23").Select
End Sub


---
Message posted from
http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sorting Range Help

Thanks for the help but I am getting an error and not sure how to solv
it! It Says *Method 'Range' of object '_Global' failed*
Here is the code I am using.

Sub Sorty()
Dim lLastRow As Long
lLastRow = Range("M65536").End(xlUp).Row
Range("B12:" & lLastRow).Select
Selection.Sort Key1:=Range("D12"), Order1:=xlAscending
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End Sub

Thanks for any help

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Sorting Range Help

The line of code
Range("B12:" & lLastRow).Select
should be
Range("B12:M" & lLastRow).Select


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"HelpMe " wrote in message
...
Thanks for the help but I am getting an error and not sure how

to solve
it! It Says *Method 'Range' of object '_Global'

failed*.
Here is the code I am using.

Sub Sorty()
Dim lLastRow As Long
lLastRow = Range("M65536").End(xlUp).Row
Range("B12:" & lLastRow).Select
Selection.Sort Key1:=Range("D12"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End Sub

Thanks for any help!


---
Message posted from http://www.ExcelForum.com/



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,173
Default Sorting Range Help

Oops

That's what comes of trying to be clever and not testing...sorry! Thanks
for bailing me out Chip ;-)

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
HIS


"Chip Pearson" wrote in message
...
The line of code
Range("B12:" & lLastRow).Select
should be
Range("B12:M" & lLastRow).Select


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"HelpMe " wrote in message
...
Thanks for the help but I am getting an error and not sure how

to solve
it! It Says *Method 'Range' of object '_Global'

failed*.
Here is the code I am using.

Sub Sorty()
Dim lLastRow As Long
lLastRow = Range("M65536").End(xlUp).Row
Range("B12:" & lLastRow).Select
Selection.Sort Key1:=Range("D12"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End Sub

Thanks for any help!


---
Message posted from http://www.ExcelForum.com/





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
sorting range Jase Excel Discussion (Misc queries) 1 September 30th 08 06:42 PM
sorting range peyman Excel Discussion (Misc queries) 5 October 27th 07 10:29 PM
Sorting by range planetdust New Users to Excel 3 October 21st 07 01:03 AM
Sorting a Range cmm Excel Discussion (Misc queries) 1 June 30th 06 01:35 PM
sorting a range cjsmith22 Excel Discussion (Misc queries) 2 November 13th 05 11:19 PM


All times are GMT +1. The time now is 10:58 AM.

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"