Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sort in Macro returning a value

Status
Not open for further replies.

gsgriffin

Technical User
Oct 17, 2002
27
0
0
I've recorded a sort into a macro and then placed into code so as to allow me to easily perform a sort and then an "un-sort".

When I perform the sort manually, everything works great. When the sort is repeated by the macro, I get a "Z" in the top-left cell of the sort area when the sort completes. When unsorting, a value of "M" is placed in the top-left cell.

I can't figure out what part of this code is causes the code to return a value.

Rows(SortArea).Select

Selection.Sort Key1:=Range("I6"), Order1:=xlAscending, Key2:=Range("H6") _
, Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom

Ideas?
 
Hi,

The macro is NOT returning a value unless you have some code that is putting a value in.

Chances are, the macro is not holding the header values.

Change the Header parameter to xlYes
Code:
Cells(6, 8).Sort Key1:=Range("I6"), Order1:=xlAscending, Key2:=Range("H6") _
        , Order2:=xlAscending, Header:=xlYes, OrderCustom:=1, MatchCase:= _
        False, Orientation:=xlTopToBottom
:)

Skip,
Skip@TheOfficeExperts.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top