View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default How to pass interior colours of specified range to a control.

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

"Peter T" <peter_t@discussions wrote in message
...
The OP will need the actual colour rather than the ColorIndex

colorVal = activeworbook.colors(cIndex)

Regards,
Peter T

"dominicb" wrote

in
message ...

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


--
dominicb
------------------------------------------------------------------------
dominicb's Profile:

http://www.excelforum.com/member.php...o&userid=18932
View this thread:

http://www.excelforum.com/showthread...hreadid=390149