listbox

  • Thread starter Thread starter jim c.
  • Start date Start date
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
 
well people... your teaching me well. I answered my own
question. I needed to setfocus outside listbox at end of
resize procedure. im not sure why this works, but it does
and i can move on to debug other areas... thanks for all
the great help here...
 
Back
Top