View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default AutoFit Infinite Loop?

Is this inside a worksheet event (worksheet_calculate)

application.enableevents = false
range("A9:C9").EntireColumn.AutoFit
application.enableevents = true

Maybe...

Josh Sale wrote:

I have an add-in that let's users manipulate potentially large sets of data.
After certain operations, my code will autofit the column widths of a
variable number of columns with code like:

range("A9:C9").EntireColumn.AutoFit

I've never had any problems with this in the past.

However one user has created a situation where the above operation never
completes (Task Manager shows Excel using 99% of the cpu until we kill the
process).

The worksheet being AutoFitted has 32,545 rows. So big but not gigantic.
I've ensured that there are no merged cells in the range before trying the
AutoFit. I've also tried doing the AutoFit one column at a time (e.g.,
range("A9").EntireColumn.AutoFit) but that loops too on the first column.

So far the only two versions of Excel I've been able to test with are Excel
2002 and Excel 2002 SP3.

Any good ideas out there?

TIA,

josh


--

Dave Peterson