Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 178
Default cells.interior.color values

All tests done in Excel 2007:

So i'm trying to make sense of this particular setting. I understand
the color index has 50-some-odd possibilities, which severely limits
the various iterations of color possible by Excel. So i came up with
the below code, which runs till it hits too many cell formats

Sub colortest()
Application.ScreenUpdating = False
Dim r As Double
Dim c As Double
Dim x As Double
x = 255
For c = 1 To 9999
For r = 1 To 255
With Cells(r, c)
.Interior.Color = x
.Value = x
End With
x = x + 255
Next r
Next c
Application.ScreenUpdating = True
End Sub

I go up in interations of 255 per hex values, but i'm still a bit in
the dark as to why it works this way.

This code works properly for a total of 65429 cells, but then on cell
65430 it says i've reached maximum number of possible cell formats (c
= 257, r = 150, x = 16684650).

Could anyone explain how excel takes a numerical value for the
interiors.color value and determines what the output color will be?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 587
Default cells.interior.color values

hi Matthew,

Sub test()
TheColor = ActiveCell.Interior.Color

Red = Int(TheColor Mod 256)
Green = Int((TheColor Mod 65536) / 256)
Blue = Int(TheColor / 65536)

MsgBox "Color " & TheColor & Chr(10) & _
"RED : " & Red & Chr(10) & _
"GREEN : " & Green & Chr(10) & _
"BLUE : " & Blue
End Sub


--
isabelle

Le 2011-05-19 13:13, Matthew Dyer a écrit :
Could anyone explain how excel takes a numerical value for the
interiors.color value and determines what the output color will be?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 587
Default cells.interior.color values

sorry I forgot to include the method for applying this color
and select a cell with a color before you run the macro


Sub test()
TheColor = ActiveCell.Interior.Color

Red = Int(TheColor Mod 256)
Green = Int((TheColor Mod 65536) / 256)
Blue = Int(TheColor / 65536)

MsgBox "Color " & TheColor & Chr(10) & _
"RED : " & Red & Chr(10) & _
"GREEN : " & Green & Chr(10) & _
"BLUE : " & Blue

ActiveCell.Offset(, 1).Interior.Color = RGB(Red, Green, Blue)

End Sub



--
isabelle

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 178
Default cells.interior.color values

On May 20, 10:07*pm, isabelle wrote:
sorry I forgot to include the method for applying this color
and select a cell with a color before you run the macro

Sub test()
TheColor = ActiveCell.Interior.Color

Red = Int(TheColor Mod 256)
Green = Int((TheColor Mod 65536) / 256)
Blue = Int(TheColor / 65536)

MsgBox "Color " & TheColor & Chr(10) & _
"RED : " & Red & Chr(10) & _
"GREEN : " & Green & Chr(10) & _
"BLUE : " & Blue

ActiveCell.Offset(, 1).Interior.Color = RGB(Red, Green, Blue)

End Sub

--
isabelle


Thanks isabelle. That code is most excellent!
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
Cells.Interior.Color question extrapulp Excel Programming 7 January 16th 09 04:33 PM
Sum all Cells with Interior Color Index not equal to 0 RyanH Excel Programming 2 May 22nd 08 04:46 PM
lock cells based on interior color MIke Excel Discussion (Misc queries) 4 December 27th 07 08:59 PM
cells interior/color index tandavina[_7_] Excel Programming 4 February 12th 06 11:28 AM
Sum all cells with interior color... Ctech[_65_] Excel Programming 4 January 11th 06 07:46 PM


All times are GMT +1. The time now is 12:22 PM.

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

About Us

"It's about Microsoft Excel"