View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default printing list box in the user form

This worked ok for me:

Option Explicit
Private Sub CommandButton1_Click()

Dim TempWks As Worksheet
Set TempWks = Workbooks.Add(1).Worksheets(1)
With Me.ListBox1
TempWks.Range("a1").Resize(.ListCount - 1, .ColumnCount).Value _
= .List
End With

Me.Hide
With TempWks
.UsedRange.Columns.AutoFit
.PrintOut preview:=True
'close and don't save
.Parent.Close savechanges:=False
End With
Me.Show

End Sub
Private Sub UserForm_Initialize()
Dim iCtr As Long
With Me.ListBox1
.ColumnCount = 3
For iCtr = 1 To 5
.AddItem "A" & iCtr
.List(.ListCount - 1, 1) = "B" & iCtr
.List(.ListCount - 1, 2) = "C" & iCtr
Next iCtr
End With
End Sub




" wrote:

Hi Everyone,
Is there anyway only print listbox in the user form or save the list
box values as a text file? I have a listbox in a user form which
sometimes has listbox1.listcount is more than 40. When you see the
listbox its ok you can scroll down to see other values after
listcount
40 but cannot see all the values in the listbox when you printing.
Is there anyway to do that?
Your help is greatly appreciated

best regards,
Baha


--

Dave Peterson