Rainbow color the Text

    Dim Colorarr(7) As Short

    Sub ColorArray()
    'Change the color index to be included here.
        Colorarr(0) = 41
        Colorarr(1) = 39
        Colorarr(2) = 17
        Colorarr(3) = 50
        Colorarr(4) = 44
        Colorarr(5) = 46
        Colorarr(6) = 3
    End Sub
    Sub RainBowColors()
        ' This module will apply rainbow font color to all the selected cells.
        Call ColorArray()
        Dim MyCell As Range
        For Each MyCell In Selection.Cells
            For i = 1 To Len(MyCell.Value)
                With MyCell.Characters(Start:=i, Length:=1).Font
                    .ColorIndex = Colorarr(i Mod 7)
                End With
            Next
        Next
    End Sub

Comments

k. nagarajan said…
This codings not work.
Anonymous said…
Slightly Modified. This is working

Sub RainBowColors()
' This module will apply rainbow font color to all the selected cells.
Dim Colorarr(7) As Integer
Colorarr(0) = 13
Colorarr(1) = 55
Colorarr(2) = 5
Colorarr(3) = 10
Colorarr(4) = 6
Colorarr(5) = 46
Colorarr(6) = 3
'*----------------------------------
Dim MyCell As Range
Dim r As Integer
r = 0
For Each MyCell In Selection.Cells
For i = 1 To Len(MyCell.Value)
With MyCell.Characters(Start:=i, Length:=1).Font
.ColorIndex = Colorarr(i Mod 7)
End With
Next
Next
End Sub


GOVIND