Column Sort

M

magix

Hi,

I want to check the column if it is sort ascendingly, if not, then will sort
it
How can I translate below into VBA code ?

If Column A is not sort ascendingly from A2 onward then
sort column A ascendingly from A2 onward
else
do something here.

Thanks.

Regards,
Magix
 
D

Dave Peterson

I wouldn't bother checking--just sort the range the way you want it.

I think that it would be easier/quicker than checking (and then possibly having
to sort).
 
M

magix

Ok. I would just sort it.

What is the appropriate code ?
Worksheets("Sheet1").Range("A2").Sort
Key1:=Worksheets("Sheet1").Columns("A"), Header:=xlGuess ? How to set for
ascending order ?
 
D

Dave Peterson

Record a macro when you select the range and sort the data based on the field
you want (in ascending order).

The recorded code will work nicely.
 
Top