Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel - setting background color from RGB code

Status
Not open for further replies.

dqrose

Technical User
Mar 17, 2006
24
GB
In Excel, is there a way to set the background color of a cell from its RGB color code? For example, if cell A1 contains the hex value FF0000 (pure red) then I want the background color of that cell to be pure red.

Many thanks for any help
 



Hi,
Code:
With Activecell 
  .interior.color = .Value
End With


Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 


Actually, this may be better in the Sheet Object Code Window...
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    With Target
        If .Value = "" Then Exit Sub
        If IsNumeric(.Value) Then _
            .Interior.Color = .Value
    End With
End Sub

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
Even better - once again, many thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top