Kamis, 16 April 2015

[ExcelVBA] Adding Color to Concatenated Cells

 

Hi All,

I have this simple problem that is driving me nuts. Basically I have card rank in column B and card suit in column C. I am concatenating the two into column D. I am trying to add color red to the concatenated hearts and diamonds. I have confirmed that I am identifying those suits with the commented out line, but I cannot apply the color to the suit. Any help is appreciated.


Public Sub ConcatCards()

Dim i As Integer

Columns(4).HorizontalAlignment = xlHAlignRight


For i = 1 To 52
    Cells(i, 4).Value = Cells(i, 2).Value & Cells(i, 3).Value
   
        If Right(Cells(i, 4), 1) = ChrW(&H2666) Or Right(Cells(i, 4), 1) = ChrW(&H2665) Then
            With ActiveCell
                .Characters(Start:=2, Length:=1).Font.Color = vbRed
            End With
            'Cells(i, 5).Value = "Yes"
        End If


Next i

Columns("b:c").EntireColumn.Hidden = True

End Sub




__._,_.___

Posted by: jeff.flanagan@duffcorp.ca
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (1)
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------

.

__,_._,___

Tidak ada komentar:

Posting Komentar