Combo Box or List Box colour

M

Mick

Hi

I use combo and list boxes regularly to insert data into a cell. I have
never been able to work out how to bring the cell background colour or font
colour along with the data. Can anyone help?

Kind Regards

Mick
 
J

jose luis

Mick

Are you using Combo and list from Forms or from ActiveControls?
Do you want to extract the color background from a cell and copty it t
the Combo or List?

Just to be sure on the problem... ;)

Regards

Jose Luis
 
M

Mick Southam

Jose

I use the Control Toolbox mostly. What I want to do is to be able to
use not only the cell value from a list stored elsewhere in the sheet,
but also the backgound colour and font colour as it is in the list.
i.e. if a cell in the list contains the value of say 10 with a font
colour of red on a yellow background. At the moment all I can se is the
value in the drop down list, but not the font colour or the background
colour.

Hope that make sense?

Kind Regards

Mick
 
J

jose luis

Hi Mick



As far as i know you when you assign color to a listbox it's to all the
entries of that list, not individual cells in the ListBox, but i'm not
sure cause i'm relativitily new to VBA.

Here is some piece of code that could help you in your search.


Code:
--------------------
Sub Colorcell()
MsgBox "Color font " & ActiveCell.Font.Color ' just to see the font color
MsgBox "Color interior " & ActiveCell.Interior.Color ' just to see the interior color
ListBox1.ListFillRange = "E5:E15"
ListBox1.ForeColor = ActiveCell.Font.Color 'assigns the color from the cell to the LIstBox
ListBox1.BackColor = ActiveCell.Interior.Color 'the same...
End Sub
--------------------



Hope it helps in some way

Regards

Jose Luis
 
G

Guest

Hi!

I seem to have a similar problem about setting the ComboBox color. I tried
to use the code in the last message, but it seemed to just give some error
about "object required". Is this code supposed to work with ComboBoxes as
well? Can I just change ListBox1.ForeColor to ComboBox.Forecolor and so on?
This just doesn't seem to work.

Greetings,
Erkka
 
J

jose luis

Erkka,

Yes you can change from ListBox to ComboBox. The example in my las
post was tried in Excel 2003, if it's not working could be because it'
for Control Tools not Forms or may be because of teh name of the ListBo
used. Check the name in the properties list, change if neccesary fro
ListBox1.ForeColor to TheName.ForeColor.

Hope this helps to make it run.

Regards

Jose Luis

Hi!

I seem to have a similar problem about setting the ComboBox color.
tried
to use the code in the last message, but it seemed to just give som
error
about "object required". Is this code supposed to work with ComboBoxe
as
well? Can I just change ListBox1.ForeColor to ComboBox.Forecolor and s
on?
This just doesn't seem to work.

Greetings,
Erkka
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top