Ver Mensaje Individual
  #5 (permalink)  
Antiguo 15/01/2010, 08:05
Avatar de mrocf
mrocf
 
Fecha de Ingreso: marzo-2007
Ubicación: Bs.As.
Mensajes: 1.103
Antigüedad: 19 años, 7 meses
Puntos: 88
De acuerdo Respuesta: Macro que busque y resalte (color de relleno)

Hola! Rafaelon. Intenta con lo siguiente:

Código PHP:
Sub BuscaY_Resalta()
Dim Hoja As Object, Search_Text As String, Celda As Range, First_Cell As String

Search_Text 
= InputBox("Ingrese número a localizar", "Búsqueda en el Libro")
If 
Search_Text = "" Then Exit Sub
Application
.ScreenUpdating = False

For Each Hoja In ActiveWorkbook.Sheets
  Set Celda 
= Hoja.Cells.Find(What:=Search_Text, LookIn:=xlValues, _
    LookAt
:=xlWhole)
  If 
Not Celda Is Nothing Then
    First_Cell 
= Celda.Address(External:=True)
    Do
      
With Celda.EntireRow.Interior
        
.ColorIndex = 6: .Pattern = xlSolid: .PatternColorIndex = xlAutomatic
      End With
      Set Celda 
= Hoja.Cells.FindNext(Celda)
    
Loop Until First_Cell = Celda.Address(External:=True)
  
End If
Next Hoja

Application
.ScreenUpdating = True
End Sub 
COMENTARIOS:

1º) For Each Hoja In ActiveWorkbook.Sheets es quien asigna al objeto "Hoja" cada una de las hojas de tu libro.

2º) LookAt:=xlWhole te indica que se busca el texto como único contenido de la celda.

3º) El método Find no selecciona la celda encontrada sino que la asiga a la variable Celda.
De ese modo y sumado a "Application.ScreenUpdating=False" la ejecución es infinitamente más rápida.

Saludos, Cacho.