Reputation: 25
I wrote some code and it will change the background color of the cell but I just want to change the color of the cell content.
I tried to look for the correct code but I could not fix it with my code.
Sub cellColor()
Dim colCount As Integer
Dim count As Integer
colCount = Selection.Tables(1).Columns.count
col = 0
If Selection.Shading.BackgroundPatternColor = RGB(255, 255, 255) Then
While col < colCount
Selection.Shading.BackgroundPatternColor = RGB(255, 114, 86)
col = col + 1
Wend
Else
Selection.Shading.BackgroundPatternColor = RGB(255, 255, 255)
End If
Exit Sub
End Sub
Upvotes: 0
Views: 258
Reputation: 19641
You need to use the Shading
of the range of the cell, not of the Selection
range.
This should work:
Selection.Cells(1).Range.Font.Shading.BackgroundPatternColor = RGB(255, 114, 86)
Upvotes: 1