View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_3_] Dave Peterson[_3_] is offline
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