excel find last column

Lance Hoffmeyer lance at augustmail.com
Thu Feb 8 16:54:26 EST 2007


Hi all,

I am trying to find the last used column in an excel sheet using win32com:

lastcol = sh.UsedRange.Columns.Count

works, but only if there is no formatting.  I want to allow formatting in  the columns.

I would rather use the code below because formatted cells are irrelevant.
using:

lastcol = sh.UsedRange.Find("*",xlPrevious,xlByColumns).Column

I get the error that xlPrevious is not defined.



I am using Activestate PythonWin 2.3.5.  makepy.py cannot be located.
Is makepy.py needed?  If so, where do I find it and how do I install
it?  Seems like I ran into this problem before but I cannot remember
how I solved it?


Lance



More information about the Python-list mailing list