Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Setting RGB colors for a set of cells.

hi,
in xl help, type the word specifications.
the number of colors in excel is limited to 56. no more.
sorry
Regards
FSt1

"Miron" wrote:

Hy there, thx for your quick replying!!I
Although I've change my script a little bit so its almost works
properly... Just try it, put some hexadecimal codes #xxxxxx in a
column, select it and run my formula ( try changing a little bit just
one color to make a gradient, like:

#332222
#332232
#332242
#332252
#332262

(for Peter T - it looks like thise but column has 800 cells with
diffrent codes :/)

and u'll see its working:

Sub ColorCellBasedOnCellValue3()

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim strHexColor As String
'Dim HexColor As String
Dim i As Byte
Dim cell As Range
i = 17
For Each cell In Intersect(Selection, ActiveCell.EntireColumn, _
ActiveSheet.UsedRange)
strHexColor = Right((cell.Value), 6)
'For i = 1 To (6 - Len(strHexColor))
'HexColor = HexColor & "0"
' Next
' HexColor = HexColor & strHexColor
Select Case cell.Value
Case Is = False
cell.Interior.ColorIndex = 0
Case Else
ActiveWorkbook.Colors(i) = RGB(CByte("&H" & Right$
(strHexColor, 2)), CByte("&H" & Mid$(strHexColor, 3, 2)), CByte("&H" &
Left$(strHexColor, 2)))
cell.Interior.ColorIndex = i
i = i + 1
End Select
Next cell
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = False
End Sub


"i" starts from 1 and gets to 56. If there is more than 56 colors its
crashing :/
so.....
I just need a bit of script to change/add new palette of colors after
"i" reaching 56, and some fancy way to put it to my script. I'm still
looking, but I will really appreciate your help...

Cheers
Miroon

On 23 Kwi, 23:29, "Peter T" <peter_t@discussions wrote:
As you've found out thepaletteis limited to 56 colours, attempting to
apply an RGB will match to the closest in thepalette. You can of course
customize any or all thepalettecolours to your own needs,

Active.workbook.Colors(n) = RGB(r,g,b) where n is 1 to 56

I don't follow what you mean by your 800 different codes to change. If that
means you have 800 RGB's, several of which are duplicates and 56 or less are
unique, customize thepalettewith the unique colours.

However if, in effect, you want 800 different colours in cells, these can
be simulated with the pattern greys 25, 50 & 75%. However to find the right
combinations of patterns and colours that most closely match your required
RGB's is a lot of work. I'm not aware of anything freely available to do
that, commercially perhaps soon.

The other approach of course, assuming you only want the colours in cells
without cell contents, is to use shapes. These can be formatted with any
colour and sized to cells, or even textboxes with text linked to cells
underneath. Then of course you might need to automatically adjust the font
colour to contrast, but that's another subject.

Failing all the above as solutions you might look atExcel2007.

Regards,
Peter T

"Miron" wrote in message

oups.com...



Hi
Iv got a huge problem with setting RGB colors inexcelfor difrent
cells
take a look on my script:


Sub ColorCellBasedOnCellValue()


Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim cell As Range
For Each cell In Intersect(Selection, ActiveCell.EntireColumn,
ActiveSheet.UsedRange)
Select Case cell.Value
Case Is = False
cell.Interior.ColorIndex = 0
Case Else
cell.Interior.color= RGB(CByte("&H" & Right$(cell.Value,
2)), CByte("&H" & Mid$(cell.Value, 3, 2)), CByte("&H" & Left$
(cell.Value, 2)))


End Select
Next cell
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = False
End Sub


It supose to change Hexadecimal code from a cell change it to RGB and
than fill its background with thatcolor. It works, exceptexceluses
its 56colorpaletteand puts own closest colors.
I was thinking to change that formula to create a separatepalettefor
each onecolorornewpalete for every 56newcolors than createnew
one until finish (thers 800 difrend codes that i have to change). The
problem is that i dont know how to do it. Can anybody help me with
this??- Ukryj cytowany tekst -


- Pokaż cytowany tekst -




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting dataseries-colors with VBA in XL2007 Holger Gerths Charts and Charting in Excel 1 March 5th 10 07:22 PM
trouble setting colors feh Charts and Charting in Excel 3 July 10th 09 06:08 AM
Dynamically setting worksheet tab colors John Excel Worksheet Functions 4 January 29th 09 06:55 PM
Setting colors of results in a column ERBERB Excel Discussion (Misc queries) 1 October 28th 05 01:21 PM
Setting colors for Controls dsimcox Excel Programming 1 December 2nd 04 04:59 PM


All times are GMT +1. The time now is 01:29 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"