Assign a Colour to part of a Cells Text?

  • Thread starter Thread starter HotRod
  • Start date Start date
H

HotRod

I'm creating a label in e.g Cell A1 using

'Build Label
SpecialLabel = SchoolName & vbLf & _
Zone & vbLf & vbLf & _
TeacherName & vbLf & _
ClassTime

IS it possible to assign a colour to just the first line "SchoolName"???
 
Hi HotRod

You can use Characters Start and length

Range("A1").Value = "Hi There"
Range("A1").Characters(Start:=1, Length:=2).Font.ColorIndex = 3
 
I found this in help.

Try this for starters

With ActiveSheet.Range("G1")
.Value = SpecialLabel
.Characters(Start:=1, Length:=Len(SchoolName)).Font.ColorIndex = 3
End With
 
Sub BBB()
SchoolName = "the big brown school"
Zone = "Elba"
TeacherName = "Sally Slewfer"
ClassTime = "8:30 AM"
SpecialLabel = SchoolName & vbLf & _
Zone & vbLf & vbLf & _
TeacherName & vbLf & _
ClassTime
Range("A1").Font.ColorIndex = xlAutomatic
Range("A1").Value = SpecialLabel
Range("A1").Characters(1, Len(SchoolName)).Font.ColorIndex = 3
End Sub
 

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

Back
Top