Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form Listbox Height Not Setting

Status
Not open for further replies.

bdmangum

Technical User
Dec 6, 2006
171
US
On a form i'm creating I'm attempting to set the height of a listbox based upon the number of items entered into the listbox. The listbox is added dynamically at runtime via code and is called ListAdd. I have a variable called ListHeight which contains the total height needed for the listbox. Here's my code:

Code:
ListAdd.RowSource = ThisWorkbook.Sheets("Project_Info").Range(Cells(2, 11), Cells(ListCount + 1, 15)).Address
ListAdd.Height = ListHeight
'MsgBox "ListAdd.Height = " & ListAdd.Height & vbLf & "ListHeight = " & ListHeight

The strange thing is that the listbox height will not set correctly, however when I inserted the msgbox line to check the values it worked. The height is always set correctly when the msgbox is displayed and it never works if the msgbox isn't displayed. Could this be a waiting issue? But that doesn't make sense because the msgbox line is after the height change code.

Anybody see something wrong in my code? Or does someone know a better way of changing a listbox height based on te number of entries?

Thanks!
BD
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top