Color Coding in Excel VBA

Опубликовано: 16 Март 2026
на канале: Excel Yoga
219
6

In this video you will learn color coding in excel using VBA.

Here I have explained
1.For Loop
2.Color Index
3.Time Delay / Pause Time
4. Input Box

Please use the below code in your visual basic editor to see the magic.

Sub delay_time()
For I = 1 To 10
Cells(1, I).Value = I
Application.Wait Now() + TimeValue("00:00:02")
Cells(1, I).Interior.ColorIndex = I
Application.Wait Now() + TimeValue("00:00:02")
Cells(I, 1).Value = I
Application.Wait Now() + TimeValue("00:00:02")
Cells(I, 1).Interior.ColorIndex = I
Application.Wait Now() + TimeValue("00:00:02")
Cells(I, I).Value = I
Application.Wait Now() + TimeValue("00:00:02")
Cells(I, I).Interior.ColorIndex = I
Next I
Call NEXTONE
End Sub

Sub NEXTONE()
For I = 2 To 9
Cells(10, I).Value = I
Application.Wait Now() + TimeValue("00:00:02")
Cells(10, I).Interior.ColorIndex = I
Next
Call NEXTTWO
End Sub

Sub NEXTTWO()
For I = 2 To 9
Cells(I, 10).Value = I
Application.Wait Now() + TimeValue("00:00:02")
Cells(I, 10).Interior.ColorIndex = I
Next
End Sub