Macro en excel: buscar

Hola
La inquietud mía es como hacer que el botón consulta funcione correctamente
si cuando le doy un dato erróneo me saca un error.
Si la alguien me puede ayudar se lo agradezco, este es el código que tengo parabuscar:
Dim lngUltimaCelda, NoEsta As Long
If WorksheetFunction.CountA(Cells) > 0 Then
 lngUltimaCelda = Cells.Find(What:=txtDoc, After:=[A1], _
  SearchOrder:=xlByRows, _
 SearchDirection:=xlPrevious).Row
End If
Muchas gracias...
Respuesta
1
Dim lngUltimaCelda, NoEsta As Long
If WorksheetFunction.CountA(Cells) > 0 Then
Set Encontrado = Cells.Find(What:=txtDoc, After:=[A1], _
  SearchOrder:=xlByRows, _
 SearchDirection:=xlPrevious)
if not Encontrado is nothing then
        lngUltimaCelda =Range(Encontrado.address).Row
        else
        msgbox "No encontrado (O lo q quieras escribir)"
end if
End If

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas