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

No, I don't.

Well, maybe your code has other spots that turn events on/off???

(but that ain't much of a hint.)

Josh Sale wrote:

Dave,

Well you're right about the AutoFit being called from an event handler. In
my case its a CommandButton_MouseUp event handler.

I tried bracketing the AutoFit with the disabling and enabling of events as
you suggested but it didn't cure the problem ... Excel still loops.

I liked the direction I think you were going so I commented out the
AutoFit and let the event handler run to completion. I then launched the
VBE and tried executing "Range("A1").EntireColumn.AutoFit" from the
immediate window and it to went into a loop.

Then I thought why don't I remove the VBA code from the equation. After
manipulating the data with the AutoFit code commented out, I tried
performing the AutoFit operation from Excel (i.e., I double-clicked on the
column seperator) that too went into a loop.

At this point I went back, recreated the data with the AutoFitting commented
out and saved the workbook. I reopend the workbook on that same machine and
attempts to AutoFit from Excel continue to fail.

I brought the saved workbook back to my machine and opened it in both Excel
97 and Excel 2003 SP2 and it won't AutoFit there either.

Now I'm all out of ideas again. Any more suggestions?

Thanks,

josh

"Dave Peterson" wrote in message
...
Is this inside a worksheet event (worksheet_calculate)

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

Maybe...


--

Dave Peterson