• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Macro to Automate Shading by Taking RGB Values from Adjacent Cells

bkanne

Member
Hey there,

I am trying to automate the shading of a few cells by extracting the RGB color values from adjacent cells. The sample spreadsheet should make it pretty clear.

It would be helpful if the code could be run via a command button, but I can add this later if it is too much trouble.

Thanks for any help!
 

Attachments

  • Sample Color Sheet_v1.xlsm
    13.4 KB · Views: 5
Bkanne

Try this code:

Code:
Sub Color_Cells()
Dim c As Range

For Each c In Range("I15:I29")
  If c.Offset(0, -4) > 0 Then
  c.Interior.Color = RGB(c.Offset(0, -4), c.Offset(0, -3), c.Offset(0, -2))
  End If
Next c

End Sub
 
Back
Top