Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 249
Default listbox - code to adjust column widths

[Excel 2003]
I use listboxes to display tables of data.

Is there a way to adjust individual column widths such that one can make the
columns fit - some of my columns need to be narrow and some wide.

Thus far I have only been able to make the first column width adjusted
(ColumnWidth Property) to what i want, but the others seem to be set to a
predefined default width.

Surely one can use code to adjust all the widths??

Roger
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default listbox - code to adjust column widths

To manually adjust the columns of a listbox in the properties window, if you
have three columns:

ColumnWidth | 20, 40, 25

Would set column 1 to 20, col 2 to 40 and col 3 to 25



"Roger on Excel" wrote in message
...
[Excel 2003]
I use listboxes to display tables of data.

Is there a way to adjust individual column widths such that one can make
the
columns fit - some of my columns need to be narrow and some wide.

Thus far I have only been able to make the first column width adjusted
(ColumnWidth Property) to what i want, but the others seem to be set to a
predefined default width.

Surely one can use code to adjust all the widths??

Roger



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default listbox - code to adjust column widths

That should be delimited by semicolons, not commas.

20; 40; 25

In Code:

UserForm1.Listbox1.ColumnWidths = 20; 40; 25

The default measurement is in points. You have to specify if you want to
use inches. See VBA help for details.


"JLGWhiz" wrote in message
...
To manually adjust the columns of a listbox in the properties window, if
you have three columns:

ColumnWidth | 20, 40, 25

Would set column 1 to 20, col 2 to 40 and col 3 to 25



"Roger on Excel" wrote in message
...
[Excel 2003]
I use listboxes to display tables of data.

Is there a way to adjust individual column widths such that one can make
the
columns fit - some of my columns need to be narrow and some wide.

Thus far I have only been able to make the first column width adjusted
(ColumnWidth Property) to what i want, but the others seem to be set to a
predefined default width.

Surely one can use code to adjust all the widths??

Roger





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 277
Default listbox - code to adjust column widths

On Sat, 28 Nov 2009 16:30:01 -0800, Roger on Excel
wrote:

[Excel 2003]
I use listboxes to display tables of data.

Is there a way to adjust individual column widths such that one can make the
columns fit - some of my columns need to be narrow and some wide.

Thus far I have only been able to make the first column width adjusted
(ColumnWidth Property) to what i want, but the others seem to be set to a
predefined default width.

Surely one can use code to adjust all the widths??

Roger


Set up the sheet you wish to have column widths copied from, and select
the top row, or only those cells you wish to copy the column widths of.
Copy then paste special in the sheet you want with "column widths" as
what you are copying. That is the hand mode. The recorded code I got was:

Sub ColumnAtribCopy()
'
' Meant to copy column widths from current
' sheet to specified sheet
' (currently sheet2)

Rows("1:1").Select
Selection.Copy
' target sheet name can be specified below
Sheets("Sheet2").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone,
_
SkipBlanks:=False, Transpose:=False
Range("A1").Select
End Sub

Replace "sheet2" with your sheet name, of course, and re-connect broken
lines due to Usenet concatenation (fourth line up).
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default listbox - code to adjust column widths

The widths shoulb be a string data type:

UserForm1.Listbox1.ColumnWidths = "20; 40; 25"

Just add quote marks.


"JLGWhiz" wrote in message
...
To manually adjust the columns of a listbox in the properties window, if
you have three columns:

ColumnWidth | 20, 40, 25

Would set column 1 to 20, col 2 to 40 and col 3 to 25



"Roger on Excel" wrote in message
...
[Excel 2003]
I use listboxes to display tables of data.

Is there a way to adjust individual column widths such that one can make
the
columns fit - some of my columns need to be narrow and some wide.

Thus far I have only been able to make the first column width adjusted
(ColumnWidth Property) to what i want, but the others seem to be set to a
predefined default width.

Surely one can use code to adjust all the widths??

Roger





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
auto adjust column widths and row height DebC Excel Discussion (Misc queries) 1 November 24th 09 03:17 PM
AUTOMATICALLY ADJUST COLUMN WIDTHS TO CONTENT DebC Excel Worksheet Functions 3 June 5th 09 05:33 PM
Automatically adjust column widths stu_padassol Excel Discussion (Misc queries) 1 July 27th 06 08:13 AM
Column widths to adjust automatically? lambola Excel Discussion (Misc queries) 1 January 21st 05 12:35 AM
How do I adjust column widths only on selected cells? karla Excel Discussion (Misc queries) 2 December 27th 04 02:10 PM


All times are GMT +1. The time now is 07:04 PM.

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"