Formatting Characters
It is possible to format different parts of a text string with the help of some VBA code.
Lets suppose we want to change the formatting of the following text so the different components are displayed in different colours and formatted differently.
Please note that this method cannot be used to format dates, only text entries.
The following lines of code loop through all the cells and manually change the formatting of each cell.
Range("B2").Select
Do While Len(ActiveCell.Value) > 0
ActiveCell.Characters(Start:=1, Length:=2).Font.ColorIndex = 9
ActiveCell.Characters(Start:=1, Length:=2).Font.Bold = True
ActiveCell.Characters(Start:=4, Length:=2).Font.ColorIndex = 22
ActiveCell.Characters(Start:=4, Length:=2).Font.Italic = True
ActiveCell.Characters(Start:=7, Length:=4).Font.ColorIndex = 49
ActiveCell.Characters(Start:=7, Length:=4).Font.Underline = True
ActiveCell.Offset(1,0).Select
Loop
© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext