Change color of characters in a cell based of a cell reference

K

kimbobo

Hi All,

Does anyone know how to change the color of characters in a cell based
of a cell reference.

For example, cell A1 = "||||||||||" (contains 10 "|") I want the first
4 "|" to be Red and the second 6 to Blue. Based of cells A2 = 4 and A3
= 6.

Any ideas?

Thanks!!

-Kim
 
D

Dave Peterson

Check your other post.
Hi All,

Does anyone know how to change the color of characters in a cell based
of a cell reference.

For example, cell A1 = "||||||||||" (contains 10 "|") I want the first
4 "|" to be Red and the second 6 to Blue. Based of cells A2 = 4 and A3
= 6.

Any ideas?

Thanks!!

-Kim
 
G

Gord Dibben

Sub CellFont()
Dim rng1, rng2 As Integer
rng1 = Range("A2").Value
rng2 = Range("A3").Value
With ActiveCell.Characters(Start:=1, Length:=rng1).Font
.ColorIndex = 3
End With
With ActiveCell.Characters(Start:=rng1 + 1, Length:=rng2).Font
.ColorIndex = 5
End With
End Sub


Gord Dibben MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top