Plantilla de búsqueda en una base de datos

Tengo una base de datos de materiales con 9 columnas y más de 700 filas,¿podría contar con una plantilla de búsqueda que me devuelva la fila completa que busco?

1 respuesta

Respuesta
1

Te anexo el código para buscar con un userform

Dim h1, h2, uc
'
Private Sub TextBox1_Change()
'Por.Dante Amor
    h2.Rows("2:" & Rows.Count).Clear
    ListBox1.RowSource = ""
    If TextBox1.Value = "" Then Exit Sub
    u = h1.Range("A" & Rows.Count).End(xlUp).Row
    Set r = h1.Range(h1.Cells(3, "A"), h1.Cells(u, uc))
    'Set r = h1.Columns("B")
    Set b = r.Find(TextBox1.Value, LookAt:=xlPart)
    If Not b Is Nothing Then
        celda = b.Address
        fila = 0
        j = 2
        Do
            'detalle
            If fila <> b.Row Then
                h1.Rows(b.Row).Copy h2.Rows(j)
                j = j + 1
            End If
            fila = b.Row
            Set b = r.FindNext(b)
            celda2 = b.Address
        Loop While Not b Is Nothing And b.Address <> celda
    End If
    u = h2.Range("A" & Rows.Count).End(xlUp).Row
    If u > 1 Then
        h2.Cells.EntireColumn.AutoFit
        For i = 1 To uc
            anch = anch & Int(h2.Cells(1, i).Width) + 3 & ";"
        Next
        ListBox1.ColumnWidths = anch
        rango = h2.Range(h2.Cells(2, "A"), h2.Cells(u, uc)).Address
        ListBox1.RowSource = h2.Name & "!" & rango
    End If
End Sub
'
Private Sub UserForm_Activate()
'Por.Dante Amor
    Set h1 = Sheets("Hoja1")
    Set h2 = Sheets("temp")
    uc = h2.Cells(1, Columns.Count).End(xlToLeft).Column
    ListBox1.ColumnCount = uc
End Sub

.

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

.

Avísame cualquier duda

.

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas