Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default How to set "top" of listbox

I am having a problem setting the height of a listbox.

I have a userform with a listbox containing all range names of the workbook.
Below this listbox are two command buttons. I want to show all range names
(usually a number between 3 and 6), so I set the height of the listbox, then
set the "Top" of the two command buttons, and then set the height of the
userform.

The following code is in the Initialize event of the userform:
ListBox1.Height = Count * 12 + 2
cmdPrint.Top = 96 + ListBox1.Height + 16
cmdClose.Top = 96 + ListBox1.Height + 16
uflPrtRng.Height = 96 + ListBox1.Height + 16 + cmdClose.Height + 16 + 20

This sets the top of the buttons to be 16 points below the bottom of the
listbox. (At least that's what I was hoping it would do!)

The trouble is that the first line seems to be ignored! If Count = 6 then
the height should be 74. I'll run the code and the height is 49.2!! Then
I'll step thru the code and the height is set to 74 and the form looks good.
I'll run the code again without stepping thru it and it's back to 49.2.

The listbox is not locked and it's initial height in design mode is 50.

Is there some other property that I don't have set correctly??

Thank You!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default How to set "top" of listbox


i do something similar to show a form depending on the number of items will
populate the list box.

i have my code in the userform.activate section.

i use a case statement to determine the value of z

With UserForm2
.Caption = ws.Range("F" & i).Value & " [" & _
ws.Range("E" & i).Value & "]"
.Width = 280 + z + 65
.Height = 63 + (z * 18)
.ListBox1.Height = 5 + z * 12
.ListBox1.Width = 170
.ListBox1.Left = 20
'.ListBox1.Enabled = False
.ListBox2.Height = 5 + z * 12
.ListBox2.Width = 60
.ListBox2.Left = 190
.ListBox3.Left = 250
.ListBox3.Width = 60
.ListBox3.Height = 5 + z * 12
.ListBox1.SetFocus
.Label1.Left = 10
.Label2.Left = 190
.Label3.Left = 250
.TextBox1.Top = 30 + z * 12
.TextBox1.Left = 190
.TextBox1.Width = 60
.TextBox1.Value = Format(totPounds, "#,###.00")
.TextBox2.Top = 30 + z * 12
.TextBox2.Left = 250
.TextBox2.Width = 60
.TextBox2.Value = Format(BatPounds, "#,###.00")
.TextBox3.Top = 30 + z * 12
.TextBox3.Left = 170
.TextBox3.Width = 20
.TextBox3.Value = z
.CommandButton1.Top = 30 + z * 12
End With
--


Gary


"Norm Lundquist" wrote in message
...
I am having a problem setting the height of a listbox.

I have a userform with a listbox containing all range names of the workbook.
Below this listbox are two command buttons. I want to show all range names
(usually a number between 3 and 6), so I set the height of the listbox, then
set the "Top" of the two command buttons, and then set the height of the
userform.

The following code is in the Initialize event of the userform:
ListBox1.Height = Count * 12 + 2
cmdPrint.Top = 96 + ListBox1.Height + 16
cmdClose.Top = 96 + ListBox1.Height + 16
uflPrtRng.Height = 96 + ListBox1.Height + 16 + cmdClose.Height + 16 + 20

This sets the top of the buttons to be 16 points below the bottom of the
listbox. (At least that's what I was hoping it would do!)

The trouble is that the first line seems to be ignored! If Count = 6 then
the height should be 74. I'll run the code and the height is 49.2!! Then
I'll step thru the code and the height is set to 74 and the form looks good.
I'll run the code again without stepping thru it and it's back to 49.2.

The listbox is not locked and it's initial height in design mode is 50.

Is there some other property that I don't have set correctly??

Thank You!



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
Listbox header inside VBA (Array("Head1", "Head2", ...) Alex St-Pierre Excel Programming 2 October 25th 06 09:28 PM
HELP on "left","right","find","len","substitute" functions serene83 Excel Discussion (Misc queries) 5 June 27th 06 02:23 AM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM


All times are GMT +1. The time now is 03:10 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"