View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Trevor Shuttleworth Trevor Shuttleworth is offline
external usenet poster
 
Posts: 1,089
Default Copying the colors of one Matrix to Another?!

Mike

you can't use the existing code because that is looking for values to change
the interior colour. Why not just record a macro that copies the existing
matrix and then does a Paste Special | Formats to the new blank matrix.
That won't pick up the colours generated by the conditional formatting
though. If you want that, you'd be better removing the Conditional
Formatting and including the other values in code.

Regards

Trevor


"Mike" wrote in message
oups.com...
Hi everyone,

Say I have a matrix:

2 5
4 1
2 2
4 4
3 2

The following piece of code will color each cell in that matrix:

Dim RngA As Range
Dim RngAInput As Variant

Set RngAInput = Range("B3:c7")
For Each RngA In RngAInput
'Determine the color
Select Case RngA.Value
Case Is = 4: Num = 40
Case Is = 2: Num = 35
Case Is = "": Num = 2
End Select
RngA.Interior.ColorIndex = Num
RngA.Font.ColorIndex = 1
Next RngA

Note that for values of 1, 3, and 5, Conditional Formatting is used
(this is why they are excluded in the code).

NOW, say I have identical blank matrix, Range("b19:c23"), that I want
to copy to it the colors of the above one.

What changes I need to make to the above code to make this happen?

Thanks alot,
Mike