Excel Blinking Cells VBA Code

preview_player
Показать описание
Excel Blinking Cell VBA

0:00 Introduction blinking cell
0:34 Developer tab
0:57 VBA code overview
2:57 Blinking cell variables
3:24 Storing all cells
4:10 Add blinking

Below you can find the VBA codes that we used in this Excel Blinking Cell VBA tutorial:

'Initializing variables
Dim score As Range
Set score = Range("C3", Range("C3").End(xlDown))

Dim scoreValue As Range

Dim blinkingCellsVect As Range

Dim highlightCellsVect As Range

Dim targetValue As Range
Set targetValue = Range("F2")
-------------------------

'Storing all cells to highlight
If Not Intersect(Target, Union(score, targetValue)) Is Nothing Then

For Each scoreValue In score
If scoreValue.Value > targetValue.Value Then
If highlightCellsVect Is Nothing Then
Set highlightCellsVect = scoreValue
Else
Set highlightCellsVect = Union(highlightCellsVect, scoreValue)
End If
ElseIf scoreValue.Value > targetValue.Value - 500 And scoreValue.Value < targetValue.Value Then
If blinkingCellsVect Is Nothing Then
Set blinkingCellsVect = scoreValue
Else
Set blinkingCellsVect = Union(blinkingCellsVect, scoreValue)
End If

End If

Next scoreValue

------------------------

'Color cells and add blinking
highlightCellsVect.Interior.ColorIndex = 35

For i = 1 To 3

blinkingCellsVect.Interior.ColorIndex = 36
Application.Wait (Now + TimeValue("0:00:01"))
blinkingCellsVect.Interior.ColorIndex = 0
Application.Wait (Now + TimeValue("0:00:01"))
blinkingCellsVect.Interior.ColorIndex = 36
Application.Wait (Now + TimeValue("0:00:01"))

Next i

End If

End Sub

---------------

This concludes our Excel Blinking Cell VBA tutorial. I'm inspired by content creators as Leila Gharani and Teacher's Tech.

#Excel #Tutorial #VBA
Рекомендации по теме
Комментарии
Автор

Youtube doesn't allow the symbols for less-than and greater-than. If you want to copy the code from the description, you need to replace &gt with a greater-than symbol and &lt with a less-than symbol.

SoftTechTutorials
Автор

This is excellent. It took a little bit to get it working, as the >, < and this line -- Application.Wait (Now + TimeValue("0:00:01​")) -- didn't copy quite right (but it was great that you included it!
It's a really elegant solution to selecting all the cells before colouring them. Really lovely example to learn about 'union' too. Thanks

siobhanallen
Автор

I have only text in cell and I want the cell should blink when particular text types in how to do that

SachinKumar-ilyy
Автор

i get the error message as Object variable or with block variable not set while in = 36

pawankareshore
Автор

If i put value as name or string then this code will work or not ?

kaanapadhiyar