ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Resizing list boxes in a form (https://www.excelbanter.com/excel-programming/292431-resizing-list-boxes-form.html)

Alan[_22_]

Resizing list boxes in a form
 
Below a section of code from the Initialise section of a
form.

The intention is to resize the list box containing Hidden
Sheet names to accomodate the sheet name.

This works fine when stepped through, but fails when the
run normally, though the Form itsself resizes as expected.

It is part of a larger routine that was originally set to
look for hidden rows or columns to unhide selectively

Can anyone shed any light on why this might only work as
expected when stepped through?

With Me
For Each c In a
If Not c.Visible Then
Xists = True
.lstColLtrs.AddItem c.Name
If .lstColLtrs.Width = 0 Then
.lstColLtrs.Width = Len(c.Name) * .lstColLtrs.Font.Size
Else
tmp = .lstColLtrs.Width
If Len(c.Name) * .lstColLtrs.Font.Size tmp Then _
.lstColLtrs.Width = Len(c.Name) * .lstColLtrs.Font.Size
End If
End If
Next c
.Caption = "Hidden Sheets"
.btnShowCols.Caption = "Show Selected Sheets"
.Width = .lstColLtrs.Width + 42
End With

Using Excel 97 at present.

Thanks in advance for any suggestions


All times are GMT +1. The time now is 02:41 PM.

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