How to fill cells with color from Excel.xlrgbColor.<name> specified in worksheet

Rhodie72

Well-known Member
Joined
Apr 18, 2016
Messages
573
Background info:
I am trying to fill out a worksheet with a colour range from VBA named colours. The idea is to place the name of the colour in the cell and
Code:
cell.offset(0,1).Interior.color=xlrgbColor.

Here is a table of color names from the Excel.xlrgbColor.<1 to 143> range
Assume start begins with [A1]. So [A2] should be filled with colour named in [A1] etc. This VBA code is what I'm after. Good luck. Hope to see an answer to this one...
rgbAliceBluergbIvoryrgbSalmon
rgbAntiqueWhitergbKhakirgbSandyBrown
rgbAquargbLavenderBlushrgbSeaGreen
rgbAquamarinergbLavenderrgbSeashell
rgbAzurergbLawnGreenrgbSienna
rgbBeigergbLemonChiffonrgbSilver
rgbBisquergbLightBluergbSkyBlue
rgbBlackrgbLightCoralrgbSlateBlue
rgbBlanchedAlmondrgbLightCyanrgbSlateGray
rgbBlueVioletrgbLightGoldenrodYellowrgbSlateGrey
rgbBluergbLightGrayrgbSnow
rgbBrownrgbLightGreenrgbSpringGreen
rgbBurlyWoodrgbLightGreyrgbSteelBlue
rgbCadetBluergbLightPinkrgbTan
rgbChartreusergbLightSalmonrgbTeal
rgbCoralrgbLightSeaGreenrgbThistle
rgbCornflowerBluergbLightSkyBluergbTomato
rgbCornsilkrgbLightSlateGrayrgbTurquoise
rgbCrimsonrgbLightSlateGreyrgbViolet
rgbDarkBluergbLightSteelBluergbWheat
rgbDarkCyanrgbLightYellowrgbWhiteSmoke
rgbDarkGoldenrodrgbLimeGreenrgbYellowGreen
rgbDarkGrayrgbLimergbYellow
rgbDarkGreenrgbLinen
rgbDarkGreyrgbMaroon
rgbDarkKhakirgbMediumAquamarine
rgbDarkMagentargbMediumBlue
rgbDarkOliveGreenrgbMediumOrchid
rgbDarkOrangergbMediumPurple
rgbDarkOrchidrgbMediumSeaGreen
rgbDarkRedrgbMediumSlateBlue
rgbDarkSalmonrgbMediumSpringGreen
rgbDarkSeaGreenrgbMediumTurquoise
rgbDarkSlateBluergbMediumVioletRed
rgbDarkSlateGrayrgbMidnightBlue
rgbDarkSlateGreyrgbMintCream
rgbDarkTurquoisergbMistyRose
rgbDarkVioletrgbMoccasin
rgbDeepPinkrgbNavajoWhite
rgbDeepSkyBluergbNavyBlue
rgbDimGrayrgbNavy
rgbDimGreyrgbOldLace
rgbDodgerBluergbOliveDrab
rgbFireBrickrgbOlive
rgbFloralWhitergbOrangeRed
rgbForestGreenrgbOrchid
rgbFuschiargbPaleGoldenrod
rgbGainsbororgbPaleGreen
rgbGhostWhitergbPaleTurquoise
rgbGoldrgbPaleVioletRed
rgbGoldenrodrgbPapayaWhip
rgbGrayrgbPeachPuff
rgbGreenYellowrgbPeru
rgbGreenrgbPink
rgbGreyrgbPlum
rgbHoneydewrgbPowderBlue
rgbHotPinkrgbPurple
rgbIndianRedrgbRed
rgbIndigorgbRosyBrown
rgbRoyalBlue

<tbody>
</tbody>

Tried this on first column and failed:
Code:
For i = LBound(ColorArray1) To UBound(ColorArray1)

    With Range("A1")
        .Offset(i, 0).Value = ColorArray1(i)
        .Offset(i, 1).Interior.ColorIndex = Excel.XlRgbColor.ColorArray1(i)
    End With

Next i: i = 0
</pick>
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
I'm sorry but I don't think it's going to be possible to resolve the strings in the cells to the related VBA constants.
 
Upvote 0
1) the xlrgbColors are being depreciated.
2) Since you've gone to the trouble to type the names into cells, you might as well type in the values they represent in the next cell.
 
Upvote 0

Forum statistics

Threads
1,215,842
Messages
6,127,231
Members
449,371
Latest member
strawberrish

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