View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
mp80237[_2_] mp80237[_2_] is offline
external usenet poster
 
Posts: 6
Default VB Formatting different colors/fontstyles in one cell

Hi,

I have the following pulled in from Access to Excel and I need to have
it automatically format for a report. This is all in one cell

06Jun for This Many Minutes High/Medium/Low
1700-2240MDT/2300-0440GMT/0700-1240HKG/1100-1640SYD
Description (can be a very long description up to 100 characters)

The first line up to the box character I want to be regular color
index 21. Than on the second line I want the first section before the
slash to be bold, color index 21. Next section after the first
slash I want bold color index 19. After second slash bold
color index 22. After 3rd slash bold color index 18 length 15.
Everything after regular color index 21. So I created below
before I knew the first line was going to be required, but it
will not work because the first line does not have a set amount of
characters like the second. The range for the first line can be
anywhere from 21 to 29 characters. Any ideas? *** FYI, it is not
letting me paste that box character in here because as you know it is
considered a "return" character. So I pasted in a symbol so you could
see what I was. Again all lines are actually in one cell. Here is my
original formula:

Sub Colors()



Dim cel As Range

For Each cel In ActiveSheet.Range("f1:f100")
If cel.Value < "" Then
With Selection.Characters(Start:=1, Length:=15).Font
.Name = "Arial"
.FontStyle = "bold"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 21
End With

With Selection.Characters(Start:=16, Length:=15).Font
.Name = "Arial"
.FontStyle = "bold"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 19
End With

With Selection.Characters(Start:=31, Length:=15).Font
.Name = "Arial"
.FontStyle = "bold"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 22
End With

With Selection.Characters(Start:=46, Length:=15).Font
.Name = "Arial"
.FontStyle = "bold"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 18
End With

With Selection.Characters(Start:=60, Length:=155).Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 21
End With
End If

Next cel

End Sub


Thank you so much for the help!!