Macro botón con Password para ocultar filas

Hola expertos, quiero hacer un macro el cual mediante un botón al oprimirlo tenga password, y si se ingresa correctamente el password oculte filas del rango "b" que estén rellenas de color rojo. Tengo el siguiente objeto desarrollado pero no me oculta las filas. Solo las oculta si el password es incorrecto (osea esta al revés).

Private Sub CommandButton1_Click()
Dim Pass As String
Pass = "123" '<= contraseña aqui
If InputBox("Contraseña:", "Acceso Restringido") <> Pass Then
MsgBox "Acceso denegado."
Range("b1").Select
While ActiveCell.Row <= Range("B65536").End(xlUp).Row
If ActiveCell.Interior.Color = RGB(255, 0, 0) Then
ActiveCell.EntireRow.Hidden = True
ActiveCell.Offset(1, 0).Select
Else
ActiveCell.Offset(1, 0).Select
End If
Wend
Exit Sub
End If
End Sub

De antemano gracias por

Respuesta
1

Prueba con lo siguiente

Private Sub CommandButton1_Click()
Dim Pass As String
Pass = "123" '<= contraseña aqui
If InputBox("Contraseña:", "Acceso Restringido") <> Pass Then
    MsgBox "Acceso denegado."
    Exit Sub
End If
Range("b1").Select
While ActiveCell.Row <= Range("B65536").End(xlUp).Row
    If ActiveCell.Interior.Color = RGB(255, 0, 0) Then
        ActiveCell.EntireRow.Hidden = True
        ActiveCell.Offset(1, 0).Select
    Else
        ActiveCell.Offset(1, 0).Select
    End If
Wend
End Sub

Saludos.Dante Amor
Si es lo que necesitas.

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas