ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Rows().AutoFit starts a calculation, but Columns().AutoFit doesn't (https://www.excelbanter.com/excel-programming/436624-re-rows-autofit-starts-calculation-but-columns-autofit-doesnt.html)

Mike H

Rows().AutoFit starts a calculation, but Columns().AutoFit doesn't
 
Hi,

I can't replicate your problem but this should stop recursive calls

Private Sub Worksheet_Calculate()
Application.EnableEvents = False
Rows("10:20").AutoFit
Application.EnableEvents = True
End Sub

Mike

"Stefano" wrote:

This example copied from the help of the WorkSheet.Calculate event works well:
Private Sub Worksheet_Calculate()
Columns("A:F").AutoFit
End Sub

But it loops forever when I replace it with:
Private Sub Worksheet_Calculate()
Rows("10:20").AutoFit
End Sub

It looks like resizing the rows (even rows outside the UsedRange) causes the
volatile functions to be calculated, while resizing the columns doesn't.

Does it make sense?
How can I resize the rows after a calculation?

Thanks,
Stefano



All times are GMT +1. The time now is 12:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com