Background colour value of cell in RGB-scale

FloFlo

New Member
Joined
Jun 20, 2018
Messages
12
Hi everyone,

As I am still pretty new to this VBA-coding, I'm still strugling with simple pieces of codes.

My input on a given sheet is a matrix of different values on RGB-scale.
I would like to run a macro to colour the background of the cell according to its value (starting at A2). As I was unable to colour the background, I coloured the text instead.
As the matrix is larger than this, and contains other colour codes, I would like to adjust the cell values. This is a simplified version of my matrix

(Simple) input:[TABLE="width: 500"]
<tbody>[TR]
[TD]Blue[/TD]
[TD]Green[/TD]
[TD]Yellow[/TD]
[/TR]
[TR]
[TD]135, 195, 231
[/TD]
[TD]207, 223, 153[/TD]
[TD]254, 243, 157[/TD]
[/TR]
[TR]
[TD]0, 140, 208[/TD]
[TD]151, 191, 13[/TD]
[TD]255, 237, 0
[/TD]
[/TR]
[TR]
[TD]0, 56, 113[/TD]
[TD]103, 135, 19[/TD]
[TD]180, 164, 0[/TD]
[/TR]
</tbody>[/TABLE]


Desired output
[TABLE="width: 500"]
<tbody>[TR]
[TD]Blue[/TD]
[TD]Green[/TD]
[TD]Yellow[/TD]
[/TR]
[TR]
[TD]135, 195, 231
[/TD]
[TD]207, 223, 153[/TD]
[TD]254, 243, 157[/TD]
[/TR]
[TR]
[TD]0, 140, 208[/TD]
[TD]151, 191, 13[/TD]
[TD]255, 237, 0
[/TD]
[/TR]
[TR]
[TD]0, 56, 113[/TD]
[TD]103, 135, 19[/TD]
[TD]180, 164, 0[/TD]
[/TR]
</tbody>[/TABLE]

Thanks,
Floris
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Try this:-
Code:
[COLOR="Navy"]Sub[/COLOR] MG26Jun37
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, dn [COLOR="Navy"]As[/COLOR] Range, sp [COLOR="Navy"]As[/COLOR] Variant
[COLOR="Navy"]Set[/COLOR] Rng = ActiveSheet.Cells(1).CurrentRegion
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] dn [COLOR="Navy"]In[/COLOR] Rng
    sp = Split(dn.Value, ",")
        [COLOR="Navy"]If[/COLOR] Not dn.Row = 1 [COLOR="Navy"]Then[/COLOR]
            dn.Interior.Color = RGB(sp(0), sp(1), sp(2))
        [COLOR="Navy"]End[/COLOR] If
    [COLOR="Navy"]Next[/COLOR] dn
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0

Forum statistics

Threads
1,224,817
Messages
6,181,149
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top