Modificar macro para seleccionar celda

¿Como puedo modificar la siguiente macro para que en lugar de mostrarme MsgBox, me seleccione la celda y cambie color de fondo.?

Sub nMasbajo()
Dim mRange As Range
Set mRange = Worksheets("Hoja1").Range("A1:C10")
Dato = Application.WorksheetFunction.Min(mRange)
MsgBox Dato
End Sub

2 Respuestas

Respuesta
1

Sería algo así:

Dim mRange As Range
Dim cell As Range
Set mRange = Worksheets("Hoja7").Range("A1:C10")
Dato = Application.WorksheetFunction.Min(mRange)
For Each cell In mRange
    If cell.Value = Dato Then
        cell.Interior.Color = RGB(255, 0, 0)
        cell.Select
    End If
Next
Respuesta

Quedaría así:

Sub nMasbajo()

Dim mRange As Range
Set mRange = Worksheets("Hoja1").Range("A1:C10")

mRange.Select

With Selection

      .Interior.Color = vbGreen

End With

End Sub

No me sirve. Selecciona todo el rango y necesito que seleccione la celda con el número más bajo.

No se me ocurre otra que esta

Sub nMasbajo()
Dim mRange As Range

Set mRange = Worksheets("Hoja1").Range("A1:C10")
dato = Application.WorksheetFunction.Min(mRange)
MsgBox dato
Cells.Find(What:=dato, After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate

End Sub

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas