Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Excel to generate RGB color swatches 2

Status
Not open for further replies.

fishbin

Technical User
Feb 5, 2005
6
US
I have Excel 2002 and I want to use it to generate RGB color swatches for printer/scanner/monitor calibrations.

I can generate one swatch, let's say in cell b2 with the RGB values (0-255)in cells a2, a3, and a4 with this sheet code:

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("a2:a4")) Is Nothing Then Exit Sub
[b2].Interior.Color = RGB([A2], [A3], [A4])
End Sub

Changing any of the "a" values in will yield a different color in b2 (merged b2:b5).

I need to repeat this for a 6x14 grid (96 swatches) on each sheet. So the next swatch left would be in d2 with the RGB values in c2:c4 and the 7th swatch would be below in b6 with the values in b6:b8.

Any ideas?

fish
 
Hi,
Code:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
   With Target
      If .Column Mod 2 = 1 And .Row >= 2 And .Row <= 4 Then
         Cells(2, .Column + 1).Interior.Color = _
            RGB(Cells(2, .Column), Cells(3, .Column), Cells(4, .Column))
      End If
   End With
End Sub

Skip,

[glasses] [red]Be advised:[/red] The dyslexic, agnostic, insomniac, lays awake all night wondering...
"Is there really a DOG?" [tongue]
 
Hi fishbin,

I'm sorry, but you won't be able to do this.

Excel works with a colour palete of 56 colours. You can use any 56 colours you like, but only a maximium of 56 different colours at any one time.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top