Sort Macro to VBA - failing

P

paolopiace

Inside my VBA code I need to sort the rows of an Excel Range based on
the content of one column of the Range.

I did record a Macro that works perfectly stand-alone. It's here
below.

But, if I cut/paste the same lines into my VBA, it does not work at
all!!

Seeking help...

Range("B2:H6").Select
Selection.Sort Key1:=Range("D2"), Order1:=xlAscending,
Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom,
_
DataOption1:=xlSortNormal
 
N

Norman Jones

Hi Paolo.

=============
Inside my VBA code I need to sort the rows of an Excel Range based on
the content of one column of the Range.

I did record a Macro that works perfectly stand-alone. It's here
below.

But, if I cut/paste the same lines into my VBA, it does not work at
all!!

Seeking help...

Range("B2:H6").Select
Selection.Sort Key1:=Range("D2"), Order1:=xlAscending,
Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom,
_
DataOption1:=xlSortNormal
=============

See the 2d array sort routine suggested in
response to your posts in the Italian NG.
 
Top