Solved

Excel, how do you get the color of a cell, want to change the background color of a checkbox to match cell color

Posted on 2008-06-23
5
600 Views
Last Modified: 2013-11-18
I have color a cell to match other borders on an excel sheet.  I dropped in a activex checkbox however the background color does not match.  When you go to properties you can change the color but standard selection list is very limited, however you can drop in the code "&H00801000&" . How do find code to match a given cell, and is there good reference for these codes.

wj
0
Comment
Question by:Bill_Jackson_Texas
  • 3
  • 2
5 Comments
 
LVL 39

Expert Comment

by:nutsch
ID: 21850896
You can use the following code to return the color index of the activecell in excel.
Sub GiveColor()
 

MsgBox "Cell color is " & selection.Interior.ColorIndex
 

End Sub

Open in new window

0
 

Author Comment

by:Bill_Jackson_Texas
ID: 21851442
Thanks,  the message box returns a code of 55, however the property box is looking for a code like
"&H00801000&"  How do you translate

wj
0
 
LVL 39

Accepted Solution

by:
nutsch earned 250 total points
ID: 21851482
I believe color index 55 would be
#333399 in HTML hex
(from what I gathered http://www.mvps.org/dmcritchie/excel/colors.htm)
0
 

Author Comment

by:Bill_Jackson_Texas
ID: 21852258
nutsch - Thanks for pointing me in the right direction.  I found a solution that work by a little extra R&D.

1. Click on cell, go to fill color pallet, and get the RGB number.
2. Convert  the RGB number to Hex. http://www.javascripter.net/faq/rgbtohex.htm
3.  The format the background of an active x background is &H00BBGGRR& or 993333 instead of 333399 or the complete would be &H00993333&.  

Worked like a champ after I got it in the right order.

Thanks again.

wj
0
 
LVL 39

Expert Comment

by:nutsch
ID: 21852379
Thanks for posting your solution. Glad to have helped.

Thomas
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MS Excel: simple question #2 10 38
Set value for ActiveX Radio Button on Excel Spreadsheet 7 36
Visio 2010 - Linking Spreadsheets 5 73
Calculating Z-SCORE inside Excel. 4 86
Before we dive into the marketing strategies involved with creating an effective homepage, it’s crucial that EE members know what a homepage is. In essence, a homepage is the introductory, or default page, of a website that typically highlights the …
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Viewers will learn the basics about Excel 2013’s new Flash Fill feature.
Viewers will learn a basic data manipulation technique of unpivoting data in Power Query for Excel 2013 and the importance of using good data. Start with data in a poor structure: Create a table on your data: Unpivot columns: Rename columns: …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now