PDA

View Full Version : Change cell color from user form



protean
04-05-2011, 09:33 AM
I use a modeless form as a basic ruler when evaluating data one line at a time. I would like to add three buttons to this form that would change the background color of the selected cells. The thing I don't know how to do is to select the color for each of the buttons. Basically, how do I access the color palatte from a user form? Would also like to access the description of each as well.

Bob Phillips
04-05-2011, 03:38 PM
Why not just colour stripe the rows?

Kenneth Hobs
04-05-2011, 09:08 PM
Welcome to the forum!

I am not sure why you would need that. The standard buttons on the ribbon should give you what you need.

If you want a dialog with the 56 colors on your palette, see John Walkenbach's example. http://spreadsheetpage.com/index.php/file/a_color_picker_dialog_box/

For color descriptions, that can vary depending on your palette colors. Maybe you will like my descriptions below.

Here are some Const values that I made up for my use. While VBA has some like vbRed which is 255, I wanted a few more. The "ci" prefix means index color. The prefix "c" means the color value.
Const cBlack = &H0 '0
Const ciBlack = 1
Const cDarkRed = &H80 '128
Const ciDarkRed = 9
Const cRed = &HFF '255
Const ciRed = 3
Const cPink = &HFF00FF '16711935
Const ciPink = 7
Const cRose = &HCC99FF '13408767
Const ciRose = 38
Const cBrown = &H3399 '13209
Const ciBrown = 53
Const cOrange = &H66FF '26367
Const ciOrange = 46
Const cLightOrange = &H99FF '39423
Const ciLightOrange = 45
Const cGold = &HCCFF '52479
Const ciGold = 44
Const cTan = &H99CCFF '10079487
Const ciTan = 40
Const cOliveGreen = &H3333 '13107
Const ciOliveGreen = 52
Const cDarkYellow = &H8080 '32896
Const ciDarkYellow = 12
Const cLime = &HCC99 '52377
Const ciLime = 43
Const cYellow = &HFFFF '65535
Const ciYellow = 6
Const cLightYellow = &H99FFFF '10092543
Const ciLightYellow = 36
Const cDarkGreen = &H3300 '13056
Const ciDarkGreen = 51
Const cGreen = &H8000 '32768
Const ciGreen = 10
Const cSeaGreen = &H669933 '6723891
Const ciSeaGreen = 50
Const cBrightGreen = &HFF00 '65280
Const ciBrightGreen = 4
Const cLightGreen = &HCCFFCC '13434828
Const ciLightGreen = 35
Const cDarkTeal = &H663300 '6697728
Const ciDarkTeal = 49
Const cTeal = &H808000 '8421376
Const ciTeal = 14
Const cAqua = &HCCCC33 '13421619
Const ciAqua = 42
Const cTurquoise = &HFFFF00 '16776960
Const ciTurquoise = 8
Const cLightTurquoise = &HFFFFCC '16777164
Const ciLightTurquoise = 34
Const cDarkBlue = &H800000 '8388608
Const ciDarkBlue = 11
Const cBlue = &HFF0000 '16711680
Const ciBlue = 5
Const cLightBlue = &HFF6633 '16737843
Const ciLightBlue = 41
Const cSkyBlue = &HFFCC00 '16763904
Const ciSkyBlue = 33
Const cPaleBlue = &HFFCC99 '16764057
Const ciPaleBlue = 37
Const cIndigo = &H993333 '10040115
Const cBlueGray = &H996666 '10053222
Const ciBlueGray = 47
Const cViolet = &H800080 '8388736
Const ciViolet = 13
Const cPlum = &H6697881 '6697881
Const ciPlum = 54
Const cLavender = &HFF99CC '16751052
Const ciLavender = 39
Const cGray90 = &H333333 '3355443
Const ciGray90 = 56
Const cGray50 = &H808080 '8421504
Const ciGray50 = 16
Const cGray40 = &H969696 '9868950
Const ciGray40 = 48
Const cGray25 = &HC0C0C0 '12632256
Const ciGray25 = 15
Const cWhite = &HFFFFFF '16777215
Const ciWhite = 2
Const cPeriwinkle = &HFF9999 '16751001
Const ciPeriwindle = 17
Const cIvory = &HCCFFFF '13434879
Const ciInvory = 19
Const cDarkPurple = &H660066 '6684774
Const ciDarkPurple = 21
Const cCoral = &H8080FF '13395456
Const ciCoral = 22
Const cOceanBlue = &HCC6600 '13395456
Const ciOceanBlue = 23
Const cIceBlue = &HFFCCCC '16764108
Const ciIceBlue = 24

Const cColor18 = &H663399 '6697881
Const ciColor18 = 18
Const cColor20 = &HFFFFCC '16777164
Const ciColor20 = 20
Const cColor25 = &H800000 '8388608
Const ciColor25 = 25
Const cColor26 = &HFF00FF '16711935
Const ciColor26 = 26
Const cColor27 = &HFFFF '65535
Const ciColor27 = 27
Const cColor28 = &HFFFF00 '16776960
Const ciColor28 = 28
Const cColor29 = &H800080 '8388736
Const ciColor29 = 29
Const cColor30 = &H80 '128
Const ciColor30 = 30
Const cColor31 = &H808000 '8421376
Const ciColor31 = 31
Const cColor32 = &HFF0000 '16711680
Const ciColor32 = 32