ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Change color of specific text within a cell? (https://www.excelbanter.com/excel-programming/367117-change-color-specific-text-within-cell.html)

[email protected]

Change color of specific text within a cell?
 
Guru Excel Programmers:

Is there any way I can make text in the same cell different colors
using VBA? If so, any pointers?


ADG

Change color of specific text within a cell?
 
Try using the macro recorder to do this, and see the VBA created. You will
want to delete some unwanted lines. Below is an example of what you might see.

Range("A1").Select
ActiveCell.FormulaR1C1 = "LLLLKKKKMMMM"
With ActiveCell.Characters(Start:=1, Length:=4).Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With ActiveCell.Characters(Start:=5, Length:=5).Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 3
End With
With ActiveCell.Characters(Start:=10, Length:=3).Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
--
Tony Green


" wrote:

Guru Excel Programmers:

Is there any way I can make text in the same cell different colors
using VBA? If so, any pointers?




All times are GMT +1. The time now is 08:43 AM.

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