J
jim c.
i have a procedure that resizes a listbox's width relevent
to width of named range. procedure works great when
userform initializes, or when listbox width is increased.
When listbox width is decreased in size, the procedure
resizes the columnwidths but not the listbox width until
the procedure runs a second time. I have tried to set all
variables back to zero at end of procedure, seting listbox
width to zero at beginning of zero, and repainting
userform at end of procedure, but nothing works. It always
returns listbox's previous width until procedure is ran a
second time... any suggestions?
**********************************************************
Public Sub autocombo22()
Dim Clmwdth As Long, Clmwdth1 As Long, Az As Long, Bz As
Long, Cz As Long, w As Long, Y As Long
Sheets("sheet1").Columns.AutoFit
Az = Sheets("sheet1").Columns("a").Width
Bz = Sheets("sheet1").Columns("b").Width
Cz = Sheets("sheet1").Columns("c").Width
Y = UserForm1.Height
w = UserForm1.Width
Clmwdth1 = Az + Bz + Cz + 14
UserForm1.lbTakeoff.Width = 1
If Clmwdth1 > w Then
UserForm1.lbTakeoff.Width = w + (w - UserForm1.InsideWidth)
Else
UserForm1.lbTakeoff.Width = Clmwdth1
End If
UserForm1.lbTakeoff.ColumnWidths = Az & ";" & Bz & ";" &
Cz & ";" & 1
UserForm1.lbTakeoff.Height = Y - (Y -
UserForm1.InsideHeight)
End Sub
to width of named range. procedure works great when
userform initializes, or when listbox width is increased.
When listbox width is decreased in size, the procedure
resizes the columnwidths but not the listbox width until
the procedure runs a second time. I have tried to set all
variables back to zero at end of procedure, seting listbox
width to zero at beginning of zero, and repainting
userform at end of procedure, but nothing works. It always
returns listbox's previous width until procedure is ran a
second time... any suggestions?
**********************************************************
Public Sub autocombo22()
Dim Clmwdth As Long, Clmwdth1 As Long, Az As Long, Bz As
Long, Cz As Long, w As Long, Y As Long
Sheets("sheet1").Columns.AutoFit
Az = Sheets("sheet1").Columns("a").Width
Bz = Sheets("sheet1").Columns("b").Width
Cz = Sheets("sheet1").Columns("c").Width
Y = UserForm1.Height
w = UserForm1.Width
Clmwdth1 = Az + Bz + Cz + 14
UserForm1.lbTakeoff.Width = 1
If Clmwdth1 > w Then
UserForm1.lbTakeoff.Width = w + (w - UserForm1.InsideWidth)
Else
UserForm1.lbTakeoff.Width = Clmwdth1
End If
UserForm1.lbTakeoff.ColumnWidths = Az & ";" & Bz & ";" &
Cz & ";" & 1
UserForm1.lbTakeoff.Height = Y - (Y -
UserForm1.InsideHeight)
End Sub