lunes, 6 de marzo de 2017

Métodos buscar datos



Sub Busca1()
    T = Timer
    Range("Valor").ClearContents
    Range("Tiempo").ClearContents
    Application.ScreenUpdating = False
    Range("Lista").Select
    While ActiveCell <> Range("Dato")
        ActiveCell.Offset(1, 0).Select
    Wend
    Range("Valor") = ActiveCell.Offset(0, 1)
    Range("Valor").Select
    Application.ScreenUpdating = True
    Range("Tiempo") = Timer - T
End Sub

-------------------------------------------------------------------------------------------------------------------

Sub Busca2()
    T = Timer
    Range("Valor").ClearContents
    Range("Tiempo").ClearContents
    Application.ScreenUpdating = False
    Dato = Range("Dato")
    Range("Lista").Select
    Cells.Find(What:=Dato, After:=ActiveCell, LookIn:=xlValues, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate
    Range("Valor") = ActiveCell.Offset(0, 1)
    Range("Valor").Select
    Application.ScreenUpdating = True
    Range("Tiempo") = Timer - T
End Sub

-------------------------------------------------------------------------------------------------------------------

Sub Busca3()
    T = Timer
    Range("Valor").ClearContents
    Range("Tiempo").ClearContents
    Dato = Range("Dato")
    Set c = Range("Lista").Find(Dato, LookIn:=xlValues)
    If Not c Is Nothing Then
        Celda = c.Address
        Range("Valor") = Range(Celda).Offset(0, 1)
    End If
    Range("Valor").Select
    Range("Tiempo") = Timer - T
End Sub

-------------------------------------------------------------------------------------------------------------------

Sub Busca4()
    T = Timer
    Range("Valor").ClearContents
    Range("Tiempo").ClearContents
    Dato = Range("Dato")
    Range("Valor") = Range("Lista").Cells.Find(Dato, , , xlWhole).Offset(0, 1)
    Range("Tiempo") = Timer - T
End Sub

-------------------------------------------------------------------------------------------------------------------

Sub Busca5()
    T = Timer
    Range("Valor").ClearContents
    Range("Tiempo").ClearContents
    Dato = Range("Dato")
    Range("Valor") = Application.Evaluate("=vlookup(Dato,Cuadro,2,0)")
    Range("Tiempo") = Timer - T
End Sub
Sub Borrar()
    Range("Valor").ClearContents
    Range("Tiempo").ClearContents
End Sub

No hay comentarios:

Publicar un comentario