Need to Print this listbox.

lucky12341

Board Regular
Joined
Nov 4, 2005
Messages
121
I am using the following code to populate ListBox1. I just want to be able to print the list box once I populate it. I don't might if I have to copy it to another sheet, I have tried so many ideas and cannot get this going. I checked with two other forums and wasn't able to get a resolution that worked either. Thanks guys.


Code:
Private Sub cmdPOFindAll_Click()
    Dim MyArray(500, 8)
    Dim FirstAddress As String
    Dim strFind As String
    Dim rSearch As Range
    Dim fndA, fndB, fndC, fndD, fndE, fndF, fndG, fndH, fndI As String
    Dim head1, head2, head3, head4, head5, head6, head7, head8, head9 As String
    Dim i As Integer
    i = 1
    Set rSearch = Sheet10.Range("b2", Range("b10425").End(xlUp))
    strFind = Me.txtPO.Value
    With rSearch
        Set c = .Find(strFind, LookIn:=xlValues)
        If Not c Is Nothing Then
            c.Select
            head1 = Range("a2").Value
            head2 = Range("b2").Value
            head3 = Range("c2").Value
            head4 = Range("d2").Value
            head5 = Range("e2").Value
            head6 = "C Qty"
            head7 = Range("g2").Value
            head8 = Range("h2").Value
            head9 = "O Qty"
            With Me.ListBox1
                MyArray(0, 0) = head1
                MyArray(0, 1) = head2
                MyArray(0, 2) = head3
                MyArray(0, 3) = head4
                MyArray(0, 4) = head5
                MyArray(0, 5) = head6
                MyArray(0, 6) = head7
                MyArray(0, 7) = head8
                MyArray(0, 8) = head9
            End With
            FirstAddress = c.Address
            Do
                fndB = c.Value
                fndA = c.Offset(0, -1).Value
                fndC = c.Offset(0, 1).Value
                fndD = c.Offset(0, 2).Value
                fndE = c.Offset(0, 3).Value
                fndF = c.Offset(0, 4).Value
                fndG = c.Offset(0, 5).Value
                fndH = c.Offset(0, 6).Value
                fndI = c.Offset(0, 7).Value
                MyArray(i, 0) = fndA
                MyArray(i, 1) = fndB
                MyArray(i, 2) = fndC
                MyArray(i, 3) = fndD
                MyArray(i, 4) = fndE
                MyArray(i, 5) = fndF
                MyArray(i, 6) = fndG
                MyArray(i, 7) = fndH
                MyArray(i, 8) = fndI
                i = i + 1
                Set c = .FindNext(c)
            Loop While Not c Is Nothing And c.Address <> FirstAddress

        End If
    End With
    'Load data into LISTBOX
    Me.ListBox1.List() = MyArray
End Sub
 

Some videos you may like

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Watch MrExcel Video

Forum statistics

Threads
1,118,812
Messages
5,574,456
Members
412,595
Latest member
slim313
Top