Solved

Excel color of Text Box same as cell

Posted on 2011-02-17
15
739 Views
Last Modified: 2012-05-11
Hi

I have Excel cells with the background
Red 0
Green 21
Blue 62
and I want an ActiveX text box over to it to have the same background
color. The backcolor is &H00400000& but is still slightly different.
How do I change this to have the same color background as the cells?
0
Comment
Question by:murbro
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 4
  • +1
15 Comments
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 34917172
Assign the cell's Interior.Color property to the textbox's BackColor property.
0
 

Author Comment

by:murbro
ID: 34917349
Hi. Where do you find the cell's Interior.Color propert
0
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 34917371
Range("A1").Interior.Color
for example.
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

Author Comment

by:murbro
ID: 34917520
using a msgbox I found that the interior color of the cell is 4068608
but how do apply this to the text box backcolor notation of &H00400000&
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 34917593
Also, &H00400000& is the same as Blue=64, Green=0 and Red=0
So you want to change that to &H003EF500&
0
 
LVL 45

Expert Comment

by:patrickab
ID: 34917616
Murbro,

In a Forms TextBox you are limited to the built in colours shown in the BackColor Properties options. See attached file.

Patrick
textbox-colour-01.xls
0
 
LVL 22

Accepted Solution

by:
rspahitz earned 500 total points
ID: 34917619
Sorry...that's &H003E1500&

Just run your number through the Windows calculator then convert to Hex (in Programmer mode)
0
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 34917731
You don't have to convert:

Sheets("Sheet1").textbox1.backcolor = Range("A1").interior.color

Open in new window


for example.
0
 
LVL 45

Expert Comment

by:patrickab
ID: 34917762
Nice one - works well.
0
 

Author Closing Comment

by:murbro
ID: 34918940
Spot on - didn't realise that was Hexidecimal.
Thanks.
Thanks to everyone else but this answer suited best,
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 34919048
Glad to help.  the other solutions would have worked if you wanted to use VBA, but it appeared you just needed the number.  Now you'll know that any time you see the &H prefix (and & suffix) it's telling you that it's talking hexadecimal :)

One other side note: the number consists of 4 parts, 2-digits each.  The right 2 are the red component, next 2 from the right are green next 2 are blue.  The leftmost 2 in some contexts (outside of Excel) are the transparency but here it refers to a code for how to interpret the rest of the number.  00 means use RGB; anything else is an index into the Windows color scheme and each number refers to something like ButtonText color, or HighlightedText color, etc.
0
 
LVL 45

Expert Comment

by:patrickab
ID: 34919892
murbro,

Strange choice of an 'Accepted' answer when:

Sheets("Sheet1").textbox1.backcolor = Range("A1").interior.color

from rorya (comment ID:34917731) works perfectly without any need to convert numbers to hexadecimal.

Patrick
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 34920493
Patrick, my interpretation was that author was only looking at the property window and not doing any VB coding.  In that context, fixing a property without doing any coding was a good choice.  But as I mentioned, the VB choices were also good ways to handle it.
0
 

Author Comment

by:murbro
ID: 34923483
Hi Patrick. I always appreciate your and Rory's help but in this instance I was manually changing properties and the answer was exactly what I needed
0
 
LVL 45

Expert Comment

by:patrickab
ID: 34924376
murbro,

Thanks for the response. Given a choice between automation and doing something manually I tend to go for automation - provided it's not too complicated. In this instance rorya's answer seemed so much more elegant than messing around with hexadecimal numbers. But each to their own.

Patrick
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

734 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