Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
sgl sgl is offline
external usenet poster
 
Posts: 80
Default ListBox Column Widths

I have a 3 column worksheet (chart of accounts - Code, Detail, Group). Each
column is of a different width. I can load these 3 columns onto a ListBox but
some of the text is not legible as all columns are of the same size in the
ListBox. Need some code to adjust column widths in the LIstBox so that all of
the text in each column is legible.

Many thanks/sgl
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 533
Default ListBox Column Widths

You can adjust the ColumnWidths right in the Properties box if the widths
are fixed, or with code at runtime:

ListBox1.ColumnWidths = "30;40;50"

--
Jim
"sgl" wrote in message
...
|I have a 3 column worksheet (chart of accounts - Code, Detail, Group). Each
| column is of a different width. I can load these 3 columns onto a ListBox
but
| some of the text is not legible as all columns are of the same size in the
| ListBox. Need some code to adjust column widths in the LIstBox so that all
of
| the text in each column is legible.
|
| Many thanks/sgl


  #3   Report Post  
Posted to microsoft.public.excel.programming
sgl sgl is offline
external usenet poster
 
Posts: 80
Default ListBox Column Widths

Jim thanks for your reply. This is the code that I have. I have tried what
you suggested but cannot seem to get it to work. What am I doing wrong?

Private Sub ListBox1_Change()

Dim SourceRange as Range

Dim Val1 As String, Val2 As String, Val3 As String

Set SourceRange = Range(ListBox1.RowSource)

ListBox1.ColumnWidths = "10;65;10"

Val1 = ListBox1.Value
Val2 = SourceRange.Offset(ListBox1.ListIndex, 1).Resize(1, 1).Value
Val3 = SourceRange.Offset(ListBox1.ListIndex, 2).Resize(1, 1).Value

' Label1.Caption = Val1 & " " & Val2 & " " & Val3

End Sub

Thanks/sgl

"Jim Rech" wrote:

You can adjust the ColumnWidths right in the Properties box if the widths
are fixed, or with code at runtime:

ListBox1.ColumnWidths = "30;40;50"

--
Jim
"sgl" wrote in message
...
|I have a 3 column worksheet (chart of accounts - Code, Detail, Group). Each
| column is of a different width. I can load these 3 columns onto a ListBox
but
| some of the text is not legible as all columns are of the same size in the
| ListBox. Need some code to adjust column widths in the LIstBox so that all
of
| the text in each column is legible.
|
| Many thanks/sgl



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 533
Default ListBox Column Widths

It doesn't look as if you're allowed to change column widths during the list
box change event. In any case that's a pretty strange place to do it
anyway.

Since the widths are always the same apparently, you should change the
column width property manually in developer mode:
-Click on the list box to select it.
-Press F4 to open Properties.
-Enter "10;65;10" (no quotes) for the ColumnWidths property.

and you're done. Kill that odd line of code.

Otherwise set the column widths in the Initialize event:

Private Sub UserForm_Initialize()
ListBox1.ColumnWidths = "10;65;10"
End Sub

--
Jim
"sgl" wrote in message
...
| Jim thanks for your reply. This is the code that I have. I have tried what
| you suggested but cannot seem to get it to work. What am I doing wrong?
|
| Private Sub ListBox1_Change()
|
| Dim SourceRange as Range
|
| Dim Val1 As String, Val2 As String, Val3 As String
|
| Set SourceRange = Range(ListBox1.RowSource)
|
| ListBox1.ColumnWidths = "10;65;10"
|
| Val1 = ListBox1.Value
| Val2 = SourceRange.Offset(ListBox1.ListIndex, 1).Resize(1, 1).Value
| Val3 = SourceRange.Offset(ListBox1.ListIndex, 2).Resize(1, 1).Value
|
| ' Label1.Caption = Val1 & " " & Val2 & " " & Val3
|
| End Sub
|
| Thanks/sgl
|
| "Jim Rech" wrote:
|
| You can adjust the ColumnWidths right in the Properties box if the
widths
| are fixed, or with code at runtime:
|
| ListBox1.ColumnWidths = "30;40;50"
|
| --
| Jim
| "sgl" wrote in message
| ...
| |I have a 3 column worksheet (chart of accounts - Code, Detail, Group).
Each
| | column is of a different width. I can load these 3 columns onto a
ListBox
| but
| | some of the text is not legible as all columns are of the same size in
the
| | ListBox. Need some code to adjust column widths in the LIstBox so that
all
| of
| | the text in each column is legible.
| |
| | Many thanks/sgl
|
|
|


  #5   Report Post  
Posted to microsoft.public.excel.programming
sgl sgl is offline
external usenet poster
 
Posts: 80
Default ListBox Column Widths

Jim thanks a lot that worked. Did it manually

"Jim Rech" wrote:

It doesn't look as if you're allowed to change column widths during the list
box change event. In any case that's a pretty strange place to do it
anyway.

Since the widths are always the same apparently, you should change the
column width property manually in developer mode:
-Click on the list box to select it.
-Press F4 to open Properties.
-Enter "10;65;10" (no quotes) for the ColumnWidths property.

and you're done. Kill that odd line of code.

Otherwise set the column widths in the Initialize event:

Private Sub UserForm_Initialize()
ListBox1.ColumnWidths = "10;65;10"
End Sub

--
Jim
"sgl" wrote in message
...
| Jim thanks for your reply. This is the code that I have. I have tried what
| you suggested but cannot seem to get it to work. What am I doing wrong?
|
| Private Sub ListBox1_Change()
|
| Dim SourceRange as Range
|
| Dim Val1 As String, Val2 As String, Val3 As String
|
| Set SourceRange = Range(ListBox1.RowSource)
|
| ListBox1.ColumnWidths = "10;65;10"
|
| Val1 = ListBox1.Value
| Val2 = SourceRange.Offset(ListBox1.ListIndex, 1).Resize(1, 1).Value
| Val3 = SourceRange.Offset(ListBox1.ListIndex, 2).Resize(1, 1).Value
|
| ' Label1.Caption = Val1 & " " & Val2 & " " & Val3
|
| End Sub
|
| Thanks/sgl
|
| "Jim Rech" wrote:
|
| You can adjust the ColumnWidths right in the Properties box if the
widths
| are fixed, or with code at runtime:
|
| ListBox1.ColumnWidths = "30;40;50"
|
| --
| Jim
| "sgl" wrote in message
| ...
| |I have a 3 column worksheet (chart of accounts - Code, Detail, Group).
Each
| | column is of a different width. I can load these 3 columns onto a
ListBox
| but
| | some of the text is not legible as all columns are of the same size in
the
| | ListBox. Need some code to adjust column widths in the LIstBox so that
all
| of
| | the text in each column is legible.
| |
| | Many thanks/sgl
|
|
|



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
Column Widths Doug Excel Worksheet Functions 1 October 6th 09 04:56 AM
Different widths for each column in a 100% stacked column chart Chart Explorer Charts and Charting in Excel 1 May 21st 09 09:19 AM
Different column widths? NorCalHomeFinance Setting up and Configuration of Excel 2 August 9th 08 09:16 PM
Column Widths Kooky Excel Discussion (Misc queries) 2 June 3rd 07 11:39 AM
Column Widths help ? GazMo[_13_] Excel Programming 1 October 26th 04 03:41 PM


All times are GMT +1. The time now is 12:59 AM.

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

About Us

"It's about Microsoft Excel"