Jump to content

Iniciar piscagem de célula quando um valor for "x"


Recommended Posts

Boas

Como fazer o código abaixo piscar "C5" quando essa célula assumir um valor "X" e parar de piscar quando o valor for zero?

Dim Executar

Sub IniciarPiscagem()

If Range("A1").Interior.ColorIndex = 3 Then

Range("A1").Interior.ColorIndex = 6

Range("B2").Interior.ColorIndex = 6

Else

Range("A1").Interior.ColorIndex = 3

Range("B2").Interior.ColorIndex = 3

End If

Executar = Now + TimeSerial(0, 0, 1)

Application.OnTime Executar, "IniciarPiscagem", , True

End Sub

Sub PararPiscagem()

Range("A1").Interior.ColorIndex = 1

Range("B2").Interior.ColorIndex = 1

Application.OnTime Executar, "IniciarPiscagem", , False

End Sub

Link to comment
Share on other sites

boas

faça um ciclo While

ao clikar numa celula qualquer,

este codigo faz piscar a celula C5 se tiver o valor «x»

adapte as suas necessidades.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim vcontador As Long
Dim vCellC5 As String
vcontador = 0
vCellC5 = LCase(Range("C5").Value)
If vCellC5 = "x" Then
vcontador = 1
Do While vcontador > 0 And vcontador < 1000
vcontador = vcontador + 1
Range("C5").Interior.ColorIndex = 3
Range("C5").Interior.ColorIndex = 0
Loop
ElseIf vCellC5 = "0" Then
Range("C5").Interior.ColorIndex = 0
End If
End Sub

cumps

acao

Edited by acao
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.