[python-win32] sort in EXCEL via pywin32

Tim Roberts timr at probo.com
Wed Dec 16 01:02:50 CET 2009


Moll, Benjamin wrote:
>
> How can I sort a column from B14:B24  considering alphabeticaly order?
>
>  
>
> /self/.xlApp.Range(/"B14:B24"/).Sort(Key1=/self/.sht.Columns( 3 ) ,
> Order1=2, Header=1)
>
>  
>
> don’t understand the meaning of key1!
>

That says to sort the data based on the 3rd column, which doesn't make
sense in your case, since you only have one column.

You should just be able to say
    xlApp.Range("B14:B24").Sort(Key1=xlApp.Range("B14"), Orientation=1)

That works for me.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the python-win32 mailing list