ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Assign a Colour to part of a Cells Text? (https://www.excelbanter.com/excel-programming/352222-assign-colour-part-cells-text.html)

HotRod

Assign a Colour to part of a Cells Text?
 
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"???



Ron de Bruin

Assign a Colour to part of a Cells Text?
 
Hi HotRod

You can use Characters Start and length

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




--
Regards Ron de Bruin
http://www.rondebruin.nl


"HotRod" wrote in message ...
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"???




AnExpertNovice

Assign a Colour to part of a Cells Text?
 
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


--
My handle should tell you enough about me. I am not an MVP, expert, guru,
etc. but I do like to help.


"HotRod" wrote in message
...
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"???





Tom Ogilvy

Assign a Colour to part of a Cells Text?
 
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

--
Regards,
Tom Ogilvy

"HotRod" wrote in message
...
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"???





HotRod

Assign a Colour to part of a Cells Text?
 
THANK YOU VERY MUCH


"HotRod" wrote in message
...
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"???





All times are GMT +1. The time now is 11:49 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com