¿Cómo imprimir todos los registros de un listbox?

Maestro DANTE AMOR, reciva un saludo cordial, espero que goce de muy buena salud. Le solicito amablemente su invaluable ayuda para corregir esta macro que no me da los resultados deseados.

Sucede que al momento de imprimir los datos del listbox NO se imprime todo el contenido.

Esta es la macro:

Private Sub Cbt_ImprimeConsulta_Click()

ThisWorkbook.Sheets("SALIDA").Visible = xlSheetVisible
Set h1 = Sheets("SALIDA")
c = ListBox1.ColumnCount
f = ListBox1.ListCount

h1.Cells(2, 2).Value = TextBox1
h1.Cells(3, 2).Value = TextBox4
h1.Cells(4, 2).Value = TextBox3
h1.Cells(5, 2).Value = TextBox2
h1.Cells(6, 2).Value = TextBox16
h1.Cells(2, 6).Value = TextBox6
h1.Cells(3, 6).Value = TextBox13
h1.Cells(4, 6).Value = TextBox5
h1.Cells(5, 6).Value = TextBox15
h1.Cells(6, 6).Value = TextBox14
h1.Cells(2, 10).Value = TextBox7
h1.Cells(3, 10).Value = TextBox8
h1.Cells(5, 10).Value = TextBox10
h1.Cells(6, 10).Value = TextBox12
h1.Cells(7, 10).Value = TextBox11
h1.Cells(4, 10).Value = TextBox9

h1.Range(h1.Cells(10, "a"), h1.Cells(f, c)) = ListBox1.List

Sheets("SALIDA").PrintOut
Sheets("SALIDA").Range("A10:P200").Value = Empty

h1.Cells(2, 2).Value = Empty
h1.Cells(3, 2).Value = Empty
h1.Cells(4, 2).Value = Empty
h1.Cells(5, 2).Value = Empty
h1.Cells(6, 2).Value = Empty
h1.Cells(2, 6).Value = Empty
h1.Cells(3, 6).Value = Empty
h1.Cells(4, 6).Value = Empty
h1.Cells(5, 6).Value = Empty
h1.Cells(6, 6).Value = Empty
h1.Cells(2, 10).Value = Empty
h1.Cells(3, 10).Value = Empty
h1.Cells(4, 10).Value = Empty
h1.Cells(5, 10).Value = Empty
h1.Cells(6, 10).Value = Empty
h1.Cells(7, 10).Value = Empty

ThisWorkbook.Sheets("SALIDA").Visible = xlSheetHidden

End Sub

Trabajo con excel 2016.

1 respuesta

Respuesta
2

H o l a:

Cambia esta línea

H1. Range(h1. Cells(10, "a"), h1.Cells(f, c)) = ListBox1. List

Por esta:

h1.Range(h1.Cells(10, "a"), h1.Cells(f + 10 - 1, c)) = ListBox1.List

' : )
'S aludos. Dante Amor. Recuerda valorar la respuesta. G racias
' : )

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas