Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Setting cell colors using RGB( ) function

I have a range of cells with different RGB values e.g.
Column 1
RGB(0,0,0)
RGB(0,255,0)

I am reading these values and in my macro and setting the color of a range
of cells
using the following statement.

rangec.Interior.Color = Worksheets("output").Cells(mrgb,
13).Value

I get an error message stating that VB is unable to set the color property
however when I hard code the value as below, the code works fine.

rangec.Interior.Color = RGB(0,255,0)

I did not want to hard code it because of the obvious reason ( for users to
change/add colours in the future)

I tries capturing the cell value in a variable ( tried string, variant) and
nothing worked. Also I tried vbRed; vbBlue etc instead of the RGB( ) function
and still the same behaviour.

Wondering if anyone has any tips?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default Setting cell colors using RGB( ) function

VBA cannot interpret your text "RGB(0,0,0)". You could put R, G, and B into
adjacent cells and use this:

With Worksheets("output")
rangec.Interior.Color = RGB(.cells(mrgb,13), .cells(mrgb,14),
..cells(mrgb,15))
End With

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"haileybury" wrote in message
...
I have a range of cells with different RGB values e.g.
Column 1
RGB(0,0,0)
RGB(0,255,0)

I am reading these values and in my macro and setting the color of a range
of cells
using the following statement.

rangec.Interior.Color = Worksheets("output").Cells(mrgb,
13).Value

I get an error message stating that VB is unable to set the color property
however when I hard code the value as below, the code works fine.

rangec.Interior.Color = RGB(0,255,0)

I did not want to hard code it because of the obvious reason ( for users
to
change/add colours in the future)

I tries capturing the cell value in a variable ( tried string, variant)
and
nothing worked. Also I tried vbRed; vbBlue etc instead of the RGB( )
function
and still the same behaviour.

Wondering if anyone has any tips?



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
Changing cell colors from a function command Joebeone Excel Worksheet Functions 3 February 13th 10 01:11 AM
Dynamically setting CELL COLORS based on TWO OTHER cell values Tom Excel Discussion (Misc queries) 3 February 22nd 09 07:34 PM
Is there a function like Vlookup that works with cell colors? Jose Excel Worksheet Functions 2 January 31st 09 05:02 AM
MY 2003 Excel does not show cell colors. Solution? Setting? WetRiverOak Excel Discussion (Misc queries) 1 August 2nd 06 04:21 AM
Using if function with cell fill colors Pam Excel Programming 4 January 29th 06 03:51 AM


All times are GMT +1. The time now is 02:09 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"