I'm having a challenge adjusting Listbox column widths to Label headers. The labels are the same width but as you can see text values are shifting.
I'm prefixing values with blank spaces with: 8 - Len(Format(sh.Cells(r, c).Value, "#,##0"))) & Format(sh.Cells(r, c).Value, "#,##0") so the values shown are a fixed length.
Your thoughts are appreciated.
Listbox Column Widths and Labels as Headers
-
- GoldLounger
- Posts: 2631
- Joined: 26 Jan 2010, 16:31
- Location: Southern California
Listbox Column Widths and Labels as Headers
You do not have the required permissions to view the files attached to this post.
Regards,
John
John
-
- Administrator
- Posts: 78671
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Listbox Column Widths and Labels as Headers
What is the Width setting of the labels?
And what is the Column Widths setting of the list box?
And what is the Column Widths setting of the list box?
Best wishes,
Hans
Hans
-
- GoldLounger
- Posts: 2631
- Joined: 26 Jan 2010, 16:31
- Location: Southern California
Re: Listbox Column Widths and Labels as Headers
Hans,
Label width = 67
Column width = 63 pt
Label width = 67
Column width = 63 pt
Regards,
John
John
-
- Administrator
- Posts: 78671
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Listbox Column Widths and Labels as Headers
I can reproduce the behavior. It looks like the columns of a listbox aren't spaced 100% regularly.
So I fear that you'll have to adjust the position and width of the labels manually.
Another option would be to set the Row Source of the listbox to the relevant range, and to set its TextAlign property to 3 - fmTextAlignRight so that the listbox items will be right-aligned. Make sure that the row above the source range contains the label captions, and set the ColumnHeads property of the listbox to True.
So I fear that you'll have to adjust the position and width of the labels manually.
Another option would be to set the Row Source of the listbox to the relevant range, and to set its TextAlign property to 3 - fmTextAlignRight so that the listbox items will be right-aligned. Make sure that the row above the source range contains the label captions, and set the ColumnHeads property of the listbox to True.
Best wishes,
Hans
Hans
-
- GoldLounger
- Posts: 2631
- Joined: 26 Jan 2010, 16:31
- Location: Southern California
-
- GoldLounger
- Posts: 2631
- Joined: 26 Jan 2010, 16:31
- Location: Southern California
Re: Listbox Column Widths and Labels as Headers
Hans,
I got it to space correctly using the Courier New font in the ListBox and Labels with the same font size.
I also had to make slight width adjustments to the labels.
I got it to space correctly using the Courier New font in the ListBox and Labels with the same font size.
I also had to make slight width adjustments to the labels.
Regards,
John
John