1

El error esta Justo en el comentario que dice BUSQUEDA POR NOMBRE DEL DIRECTOR. Temo que vaya a generar el mismo para todo el código, ya que todo ha sido copiado y pegado multiples veces; sé que se puede optimizar de muchas formas, pero mi interés en este momento es quitar el error. Les agradezco mucho.

Private Sub Buscar_Click()
Application.ScreenUpdating = False

items = Range("A2:L400").CurrentRegion.Rows.Count

For i = 1 To items

    'BUSQUEDA POR NOMBRE DEL DIRECTOR
    ElseIf LCase(Cells(i, 7).Value) Like "*" & LCase(Me.Palabra_Text.Value) & "*" Then
    Me.Lista_Cd.AddItem Cells(i, 1)
    Me.Lista_Cd.List(Me.Lista_Cd.ListCount - 1, 1) = Cells(i, 2)
    Me.Lista_Cd.List(Me.Lista_Cd.ListCount - 1, 2) = Cells(i, 3)
    Me.Lista_Cd.List(Me.Lista_Cd.ListCount - 1, 3) = Cells(i, 4)
    Me.Lista_Cd.List(Me.Lista_Cd.ListCount - 1, 4) = Cells(i, 5)
    Me.Lista_Cd.List(Me.Lista_Cd.ListCount - 1, 5) = Cells(i, 6)
    Me.Lista_Cd.List(Me.Lista_Cd.ListCount - 1, 6) = Cells(i, 7)

   'Busqueda por año
    ElseIf LCase(Cells(i, 11).Value) Like "*" & LCase(Me.Palabra_Text.Value) & "*" Then
    Me.Lista_Cd.AddItem Cells(i, 1)
    Me.Lista_Cd.List(Me.Lista_Cd.ListCount - 1, 1) = Cells(i, 2)
    Me.Lista_Cd.List(Me.Lista_Cd.ListCount - 1, 2) = Cells(i, 3)
    Me.Lista_Cd.List(Me.Lista_Cd.ListCount - 1, 3) = Cells(i, 4)
    Me.Lista_Cd.List(Me.Lista_Cd.ListCount - 1, 4) = Cells(i, 5)
    Me.Lista_Cd.List(Me.Lista_Cd.ListCount - 1, 5) = Cells(i, 6)
    Me.Lista_Cd.List(Me.Lista_Cd.ListCount - 1, 6) = Cells(i, 7)


    End If

    Next i
    Me.Palabra_Text.SetFocus
    Me.Palabra_Text.SelStart = 0
    Me.Palabra_Text.SelLength = Len(Me.Palabra_Text.Text)

    Exit Sub



Application.ScreenUpdating = True

End Sub
3
  • 2
    Estas comenzando el bloque con un ElseIf. ¿No debería ser If LCase(Cells(i, 7).Value) Like "*" & LCase(Me.Palabra_Text.Value) & "*" Then?
    – zeross
    el 22 jul. 2019 a las 11:37
  • Que pena, pero es que tuve que borrar parte del código el 22 jul. 2019 a las 16:21
  • En qué línea te sale marcado el error?
    – Damian
    el 24 jul. 2019 a las 12:50

1 respuesta 1

0

Prueba a cambiar

ElseIf LCase(Cells(i, 7).Value) Like "*" & LCase(Me.Palabra_Text.Value) & "*" Then

Por

If LCase(Cells(i, 7).Value) Like "*" & LCase(Me.Palabra_Text.Value) & "*" Then

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.