Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Auto adjusting a user form

Hi,



Below is some code that populates a list box with the used range of a
worksheet and puts check boxes next to them.



How can I adjust this code to:

Show the first line as a header row (no check boxes)

Is it possible to auto adjust the row height or make the text wrap inside
the list box? Basically, some of the cells in the worksheet contain a lot of
text that wraps in the cell and I would like it to do the same inside the
list box.



Thanks





Private Sub UserForm_Initialize()

Dim ColCnt As Integer

Dim rng As Range

Dim cw As String

Dim c As Integer



ColCnt = ActiveSheet.UsedRange.Columns.Count

Set rng = ActiveSheet.UsedRange

With ListBox1

.ColumnCount = ColCnt

.RowSource = rng.Address

cw = ""

For c = 1 To .ColumnCount

cw = cw & rng.Columns(c).Width & ";"

Next c

.ColumnWidths = cw

.ListIndex = 0

End With

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Auto adjusting a user form

David,

The RowSource address for the list box must exclude the header row.
The ColumnHeads property for the list box must be set to True.
I don't know of anyway to adjust the height of the list box rows.
Regards,
Jim Cone
San Francisco, USA

'-----------------------
Private Sub UserForm_Initialize()
Dim ColCnt As Integer
Dim rng As Range
Dim cw As String
Dim c As Integer

ColCnt = ActiveSheet.UsedRange.Columns.Count
Set rng = ActiveSheet.UsedRange
Set rng = rng.Offset(1, 0).Resize(rng.Rows.Count - 1)
With ListBox1
.ColumnCount = ColCnt
.RowSource = rng.Address(external:=True)
For c = 1 To .ColumnCount
cw = cw & rng.Columns(c).Width & ";"
Next c
.ColumnWidths = cw
.ListIndex = 0
End With
Set rng = Nothing
End Sub
'------------------------

"David Looney"
wrote in message

Hi,
Below is some code that populates a list box with the used range of a
worksheet and puts check boxes next to them.
How can I adjust this code to:
Show the first line as a header row (no check boxes)
Is it possible to auto adjust the row height or make the text wrap inside
the list box? Basically, some of the cells in the worksheet contain a lot of
text that wraps in the cell and I would like it to do the same inside the
list box.
Thanks

Private Sub UserForm_Initialize()
Dim ColCnt As Integer
Dim rng As Range
Dim cw As String
Dim c As Integer
ColCnt = ActiveSheet.UsedRange.Columns.Count
Set rng = ActiveSheet.UsedRange
With ListBox1
.ColumnCount = ColCnt
.RowSource = rng.Address
cw = ""
For c = 1 To .ColumnCount
cw = cw & rng.Columns(c).Width & ";"
Next c
.ColumnWidths = cw
.ListIndex = 0
End With
End Sub
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 email - With every new entry on my user form Vikram Excel Discussion (Misc queries) 0 June 19th 06 06:00 AM
Auto Adjusting Text Box Jae Excel Discussion (Misc queries) 0 August 11th 05 06:19 PM
Auto fill text boxes in user form by inputting data in another Finny33 Excel Programming 1 September 13th 04 12:53 PM
Auto-starting a User Form Bob Kaku Excel Programming 0 August 13th 03 04:21 AM
Auto loading of a user form sometimes -\) Excel Programming 1 August 2nd 03 12:32 AM


All times are GMT +1. The time now is 09:26 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"