Color de celdaS si cumple función
Hola! Cómo haría con VBA, para que (según lo que escriba en mi textbox1) UNICAMENTE las celdas en el rango "b3:¿n30" que tengan el valor del textbox1 al pulsar un commandbutton1 esas mismas celdas de se vuelvan de color azul?
Intente usar:
.
Private Sub CommandButton1_Click()
On Error Resume Next
Application.DisplayAlerts = False
Sheets("programa").Range("b3:n40").Select
If Not Selection.Value = TextBox1.Value Then
With Selection.Interior
.ColorIndex = 7
.Pattern = xlSolid
End With
End If
If Selection.Value = TextBox1.Value Then
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
End If
End sub
.
Pero no me funciono, esta me llena todo el rango del mismo color y yo solo quiero que sean las que tengan el valor del textbox1
Intente usar:
.
Private Sub CommandButton1_Click()
On Error Resume Next
Application.DisplayAlerts = False
Sheets("programa").Range("b3:n40").Select
If Not Selection.Value = TextBox1.Value Then
With Selection.Interior
.ColorIndex = 7
.Pattern = xlSolid
End With
End If
If Selection.Value = TextBox1.Value Then
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
End If
End sub
.
Pero no me funciono, esta me llena todo el rango del mismo color y yo solo quiero que sean las que tengan el valor del textbox1
2 Respuestas
Respuesta de leandropaul
1
Respuesta de prozac
1