Sort Macro for Named Ranges

  • Thread starter Fredriksson via OfficeKB.com
  • Start date
F

Fredriksson via OfficeKB.com

I rrecorded 2 Sort Macros then I change the Range to reference the Name
Range. The problem is when one Sort command working correctly the other one
blowsup.

is there a way to write I macro that will sort the different named ranges



Range("COAXrefRange").Sort Key1:=Range("A2"), Order1:=xlAscending, Header:
= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom,
_
DataOption1:=xlSortNormal


Range("PropertyXrefRange").Sort Key1:=Range("A2"), Order1:=xlAscending,
Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom,
_
DataOption1:=xlSortNormal
 
D

Dave Peterson

with range("coaxrefrange")
.cells.sort key1:=.columns(1), order1:=xlascending, header:=xlguess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
end with

And repeat it for the second range.

By the way, if you know your range has headers (or doesn't have headers), then
you might as well specify it in your code -- don't let excel guess if you know
what it should be.
 
F

Fredriksson via OfficeKB.com

Thabk you

Dave said:
with range("coaxrefrange")
.cells.sort key1:=.columns(1), order1:=xlascending, header:=xlguess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
end with

And repeat it for the second range.

By the way, if you know your range has headers (or doesn't have headers), then
you might as well specify it in your code -- don't let excel guess if you know
what it should be.
I rrecorded 2 Sort Macros then I change the Range to reference the Name
Range. The problem is when one Sort command working correctly the other one
[quoted text clipped - 17 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top