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
Cells(i, 4).Characters(Start:=2, Length:=1).Font.Color = vbRed
'Cells(i, 5).Value = "Yes"
End If
Next i
Columns("b:c").EntireColumn.Hidden = True
End Sub
----- Original Message -----Sent: Friday, April 17, 2015 12:10 PMSubject: [ExcelVBA] Adding Color to Concatenated CellsHi 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
No virus found in this message.
Checked by AVG - www.avg.com
Version: 2015.0.5863 / Virus Database: 4331/9556 - Release Date: 04/16/15
Posted by: "David Smart" <smartware.consulting@gmail.com>
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (2) |
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