¿Como puedo hacer una Macro para pasar los datos del listbox a la hoja y vista preliminar?

Pregunta dirigida a Dante, después que los datos están incluidos en el listbox como puedo hacer para que se muestren en la hoja de tickets, además tener una vista previa antes de la impresión. 

Respuesta
1

Te anexo el código del formulario:

Private Sub CommandButton4_Click()
'Por.Dante Amor
    'Imprimir
    If ListBox1.ListCount = 0 Then
        MsgBox "No hay registros a imprimir"
        Exit Sub
    End If
    Application.ScreenUpdating = False
    Set h1 = Sheets("Ticket")
    Set h2 = Sheets("Formato")
    h1.Range("A:D").Clear
    h2.Range("A:D").Copy h1.[A1]
    wt = 13
    f = 6
    '
    For i = ListBox1.ListCount - 1 To 0 Step -1
        h1.Rows(f).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
        h1.Cells(f, "B") = ListBox1.List(i, 0)
        h1.Cells(f, "C") = ListBox1.List(i, 1)
        h1.Cells(f, "D") = ListBox1.List(i, 2)
        wtot = wtot + Val(ListBox1.List(i, 3))
        wt = wt + 1
    Next
    h1.Cells(wt, "D") = TextBox6
    Application.ScreenUpdating = True
    Set b = h1.Columns("B").Find("Total", lookat:=xlWhole)
    If Not b Is Nothing Then
        h1.PageSetup.PrintArea = "$B$1:$D$" & b.Row + 3
    Else
        h1.PageSetup.PrintArea = "$B$1:$D$16"
    End If
    Me.Hide
    h1.PrintPreview
    Me.Show
End Sub

Saludos.Dante Amor

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas