Visual Basic para Aplicaciones - como mantener el columnheads luego de una busqueda

Life is soft - evento anual de software empresarial
 
Vista:
sin imagen de perfil
Val: 10
Ha aumentado su posición en 9 puestos en Visual Basic para Aplicaciones (en relación al último mes)
Gráfica de Visual Basic para Aplicaciones

como mantener el columnheads luego de una busqueda

Publicado por Dionner (6 intervenciones) el 17/08/2019 05:38:14
hola a todos, espero que se encuentren bien, tengo el siguiente problema tengo un listbox para hacer una búsqueda al principio me aparece el encabezado y luego de la búsqueda las celdas del encabezado me aparecen en blanco, es decir los datos de búsqueda aparecen correctamente pero el encabezado no quisiera que por favor me ayuden a solucionar este problema, pues tengo 23 celdas y debo identificarlas de esta forma para no colocar etiquetas ya que con las etiquetas me seria imposible. muestro el código de la búsqueda por aqui. ESPERO ME PUEDAN AYUDAR

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
Private Sub CommandButton1_Click()
 
    If Me.TextBox1.Value = Empty Then 'SI ESTA VACIO PIDE UN DATO A BUSCAR
            MsgBox "Escriba un registro para buscar"
            On Error Resume Next
            Me.ListBox1.Clear
            Me.ListBox1.RowSource = Clear
            Me.TextBox1.SetFocus
            Exit Sub
    Else
        If Me.TextBox1.Value <> Empty Then
            On Error Resume Next
            Me.ListBox1.Clear
            Me.ListBox1.RowSource = Clear
            items = Range("Tabla2").CurrentRegion.Rows.Count
            Me.ListBox1.List = Range("A1:W1").Value
            band = 0                              'BANDERA DE CONTROL DE BUSQUEDA
            Me.ListBox1.RemoveItem 0
            For I = 2 To items + 1
                cedula = Cells(I, 11).Value
                If cedula Like Me.TextBox1.Value Then
                    Me.ListBox1.ColumnHeads = True
                    Me.ListBox1.AddItem Cells(I, 1).Value
                    For J = 0 To 23   'ESTE CICLO  ME AYUDA A CARGAR TODAS LAS CELDAS DE UNA FILA
                        Me.ListBox1.List(Me.ListBox1.ListCount - 1, J) = Cells(I, J + 1).Value
                    Next J
                    band = 1
                End If
            Next I
        End If
    End If
        If cedula = Empty And band = 0 Then                      'SI LLEGA AL FINAL Y LA BANDERA DE CONTROL ES FALSA 
            MsgBox "No Se Enconcró la cedula Solicitada"    'NOTIFICA QUE NO EXISTE  ESE DATO
        End If
        'Me.TextBox1.Text = ""
        'Me.ListBox1.RemoveItem 0
        Me.ListBox1.RowSource = "Tabla2"
        Me.TextBox1.SetFocus
        Me.TextBox1.SelStart = 0
        Me.TextBox1.SelLength = Len(Me.TextBox1.Text)
End Sub
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder