Dear MrExcel community,
I search & fill listbox with textbox then I print listbox values with this code;
Listbox codes;
But some columns datas not fit. I need to set columns width.
Thank you for your time and interest!
I search & fill listbox with textbox then I print listbox values with this code;
VBA Code:
Private Sub cmdPrint_Click()
If ListBox1.ListCount = 0 Then
MsgBox “There is no data for print”
Exit Sub
End If
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim i As Workbook
Set i = Workbooks.Add
Range(“A2”).Resize(ListBox1.ListCount, ListBox1.ColumnCount).Value = ListBox1.List
Unload Me
i.Sheets(1).ExportAsFixedFormat Type:=xlTypePDF, Filename:=ThisWorkbook.Path & “\” & “List.pdf”
i.Close False
Listbox codes;
VBA Code:
Private Sub UserForm_Initialize()
ListBox1.ColumnCount = 33
ListBox1.Liste = Range(“A2:AG750”).Value
VBA Code:
Thank you for your time and interest!