Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default print listbox contents

Maybe just loop through the contents (write to a temporary worksheet) and then
print that:

Option Explicit
Private Sub CommandButton1_Click()

Dim i As Long
Dim j As Long

For i = 0 To Me.ListBox1.ListCount - 1
For j = 0 To Me.ListBox1.ColumnCount - 1
MsgBox Me.ListBox1.List(i, j)
Next j
Next i

End Sub
Private Sub UserForm_Initialize()

Dim i As Long
Dim j As Long

With Me.ListBox1
.ColumnCount = 10
.ColumnWidths = 0.3
For i = 1 To 5
.AddItem Worksheets("sheet1").Cells(i, "A").Value
For j = 1 To 9
.List(.ListCount - 1, j) _
= Worksheets("sheet1").Cells(i, "A").Offset(0, j).Value
Next j
Next i
End With

End Sub


GUS wrote:

How can i print th contents of a listbox with 10 columns ?


--

Dave Peterson

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default print listbox contents

I like Tom's answer to your later post better than the looping I did.

Dave Peterson wrote:

Maybe just loop through the contents (write to a temporary worksheet) and then
print that:

Option Explicit
Private Sub CommandButton1_Click()

Dim i As Long
Dim j As Long

For i = 0 To Me.ListBox1.ListCount - 1
For j = 0 To Me.ListBox1.ColumnCount - 1
MsgBox Me.ListBox1.List(i, j)
Next j
Next i

End Sub
Private Sub UserForm_Initialize()

Dim i As Long
Dim j As Long

With Me.ListBox1
.ColumnCount = 10
.ColumnWidths = 0.3
For i = 1 To 5
.AddItem Worksheets("sheet1").Cells(i, "A").Value
For j = 1 To 9
.List(.ListCount - 1, j) _
= Worksheets("sheet1").Cells(i, "A").Offset(0, j).Value
Next j
Next i
End With

End Sub

GUS wrote:

How can i print th contents of a listbox with 10 columns ?


--

Dave Peterson


--

Dave Peterson

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
copying the contents of a drop down list from the listbox itself? Digi777 Excel Discussion (Misc queries) 0 January 25th 10 10:06 PM
how do you print the contents of only one cell kh2533 New Users to Excel 1 October 16th 09 12:34 PM
listbox B conditional of input in Listbox A Kim K Excel Discussion (Misc queries) 1 October 31st 06 08:27 PM
contents of cells do not print Linda W Excel Worksheet Functions 2 March 9th 05 09:09 PM
Copying contents of a listbox B[_2_] Excel Programming 0 August 7th 03 02:55 PM


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