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:
BlueGreenYellow
135, 195, 231
207, 223, 153254, 243, 157
0, 140, 208151, 191, 13255, 237, 0
0, 56, 113103, 135, 19180, 164, 0

<tbody>
</tbody>


Desired output
BlueGreenYellow
135, 195, 231
207, 223, 153254, 243, 157
0, 140, 208151, 191, 13255, 237, 0
0, 56, 113103, 135, 19180, 164, 0

<tbody>
</tbody>

Thanks,
Floris
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
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,215,008
Messages
6,122,672
Members
449,091
Latest member
peppernaut

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