How to pass interior colours of specified range to a control.

G

Guest

Is is possible to load the interior colours of a range of cells into control?
That is I have a range A1:A5 -all of which have different interior cell
colours. I want to be able to pass these actual interiour colours (not their
interior colour numbers) to a control and choose them for search criteria.
So effectively, upon displaying the colours, I decide that I want the colour
of cell A1 (cell.InteriorColour = Yellow), and I search for other cells with
that colour.

I know I can also use the John Walkenbach colour palette and potentially
load it with the colours from this range and then turn the enable propertly
of the remaining buttons to FALSE if need be.

Thanks
 
D

dominicb

Good afternoon Excel monkey

The code below will pass the colours from a selected range to a
variable (b) and then display these in a msgbox. The msgbox is just to
prove that it works.

Sub colours()
Dim UsrRnge, a(), b, c, d
b = Selection.Cells.Count
c = 1
ReDim a(b)
For Each UsrRnge In Selection
a(c) = UsrRnge.Interior.ColorIndex
c = c + 1
Next UsrRnge

For d = 1 To b
MsgBox a(d)
Next d
End Sub


This code could be streamlined, but I've left it as simple as possible
with individual steps to show exactly how it has been done.

HTH

DominicB
 
P

Peter T

The OP will need the actual colour rather than the ColorIndex

colorVal = activeworbook.colors(cIndex)

Regards,
Peter T
 
T

Tom Ogilvy

Sounded more to me like he wanted names like Pink, Yellow and Blue. But who
knows.
--
Regards,
Tom Ogilvy

Peter T said:
The OP will need the actual colour rather than the ColorIndex

colorVal = activeworbook.colors(cIndex)

Regards,
Peter T

message news:[email protected]...
 
P

Peter T

Sounded more to me like he wanted names like Pink, Yellow and Blue. But
who

You might be right, but it looks like we are not destined to know either
way.

Regards,
Peter T
 

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